Specifications
Commands - 52
IF / THEN / ELSE
Statement
SYNTAX: IF m THEN statement(s) [ELSE statement(s)]
IF m GOTO line/label
IF m THEN line/label
PURPOSE: To make decisions regarding program flow based on the results returned by an expression.
REMARKS: If the expression m is true (not zero), the THEN clause is executed. THEN may be followed by
either a line number for branching or one or more statements to be executed.
If the result of m is false (zero), the THEN line is ignored and the ELSE line, if present, is executed.
Otherwise execution continues with the next executable statement.
THEN or ELSE may be followed by either a line number for branching, or one or more statements to
be executed. IF/THEN/ELSE statements may be nested.
10 IF A=B THEN C=2 ELSE IF A=J THEN PRINT J
If an IF. .THEN statement is followed by a line number in the Immediate Mode, a <Line not
found> error results, unless a statement with the specified line number had been previously entered
in the Program Mode.
NOTE: If a label is used, it must be the last statement on the line. If a label follows GOTO or
THEN, there cannot be an ELSE.
EXAMPLE: 10 IF PEEK(5000)=27 THEN B=34 ELSE B=12
ERROR: <Expected THEN> – if THEN missing
<Can’t compile> – if line/label does not exist