Syntax

if (expression) {
 instruction
 instruction
 ...
}

OR:

if (expression) {
 instruction
 instruction
 ...
} else {
 instruction
 instruction
 ...
}

OR:

if expression then instruction else instruction

OR:

if expression then {
 instruction
 instruction
 ...
} else {
 instruction
 instruction
 ...
}

 

So the key word THEN can be omitted. The ELSE part is optional. IF ... THEN ... ELSE conditions can be nested too, so instead of an instruction you can insert a new IF ... THEN ... ELSE. An expression is usually enclosed by round brackets.

Meaning

If the result of the expression is TRUE, only the instruction or the instruction block following THEN will be carried out. If the expression results in FALSE, the instruction or the block following ELSE is carried out (if present).

See also

Conditional loops