If ... else

Syntax

if expression
(tab)statements
(tab)...
[else
(tab)statements
(tab)...]

 

Can be single line:

if(expression) statements
[else statements]

 

or

if(expression) statements [else statements]

 

Parameters

expression - any expression.

 

Remarks

If expression is true (not 0), executes statements after if and skips statements after else (if used). Else skips statements after if and executes statements after else (if used).

 

else if does not require double indentation of following lines. See example.

 

See also: Operators, ifa, ifk, iif sel

 

Examples

if i=10
	out "i is 10"

if i=10
	out "i is 10"
else
	out "i is not 10"

if i > 0
	out "i is greater than 0"
	if(s.endi(".exe")) ret i; else ret 0
else if i < 0
	out "i is less than 0"
else
	out "i is 0"

if a and b
	out "a is not 0, and b is not 0"
	if c or d or e
		out "c is not 0, or d is not 0, or e is not 0"