IF expression THEN
statements
ENDIF
IF expression THEN
statements
ELSE
statements
ENDIF
Marks the end of a multi-line IF block. ENDIF may follow either the THEN block (no ELSE) or the ELSE block.
Behaviour
- A multi-line IF begins with IF expression THEN and must be closed by a matching ENDIF.
- An optional ELSE may appear before the closing ENDIF.
- ENDIF matches the nearest unmatched IF.
Examples
IF with no ELSE
IF SCORE >= 100 THEN
PRINT "LEVEL UP!"
ENDIF
IF with ELSE
IF READY THEN
PRINT "GO!"
ELSE
PRINT "WAIT..."
ENDIF
Nested IF blocks
IF A > 0 THEN
IF B > 0 THEN
PRINT "A and B are positive"
ELSE
PRINT "A is positive, B is not"
ENDIF
ELSE
PRINT "A is not positive"
ENDIF
See also: IF ยท ELSE