Retro Rocket OS
BASIC-Powered Operating System
Loading...
Searching...
No Matches
ENDIF Keyword
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.

Remarks
Only ENDIF is accepted. END IF (with a space) is not recognised.

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.
Remarks
The single-line form
IF expression THEN statement ELSE statement
does not use ENDIF.

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