IF – THEN – ELSEIF – ELSE – ENDIF

The IF-THEN-ELSEIF-ELSE-ENDIF control structure enables the conditional execution of program sections based on conditions. The ELSEIF and ELSE branches are optional.

The syntax is

IF condition THEN
… instructions …
[IF condition THEN
… instructions …]
[ELSE
… instructions …]
ENDIF

The condition is a logical comparison in the form expression logical operator expression.

Example

FOR I = 1 TO 10 STEP 1
A = I MOD 2
IF A = 0 THEN
PRINT "STRAIGHT"
ELSE
PRINT "ODD"
ENDIF
NEXT