
Commands - 57
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 progr am flow based on the results returned by an expression.
REMARK S: If the expression m is true (not zero), the TH EN 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 THE N line is ignored and the ELSE line, if present, is executed.
Otherwise execution continues w ith the next exec utable statem ent.
THE N or ELSE may be followed by e ither a line number for branching, or one or more statements
to be executed. IF/THEN/E LSE 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 THE N> – if THEN missing
< Can’t compile> – if line/label does not exist
Commentaires sur ces manuels