IF Statements
IF Statements

IF Statements

If the value of the
<Boolean expression>
in an
IF
statement is true and a program line follows the keyword
THEN
, this program line is executed. If the value of the Boolean expression is false and a program line follows the keyword
ELSE
, this program line is executed. If
ELSE
is not present, then execution continues in sequence, with the line following the
END
IF
statement.
Nesting of blocks is permitted, subject to the same nesting constraints as
DO-LOOP
s (no overlapping blocks).
ELSE IF
statements are treated as an
ELSE
line followed by an
IF
line, with the exception that the
ELSE IF
shares the
END IF
line of the original
IF
statement.
Format
IF <Boolean expression> THEN
~~BODY~~
[ELSE IF <Boolean expression> THEN
~~BODY~~]*
[ELSE
~~BODY~~]
END IF
Parameters
N/A
Example
This is an example of how to use the IF statement command:
10 IF A$="0" TyHEN 20 PRINT "ZBI IS FUN" 30 ELSE IF A$="1" THEN 40 PRINT "ZBI IS EASY" 50 ELSE IF TIME=1 THEN 60 PRINT "It is one second past midnight" 70 ELSE 80 PRINT "X=0" 90 END IF