If / then / else – Remote Processing CAMBASIC User Manual
Page 90

Comm ands - 57
IF / THEN / ELSE
Statement
SYNTAX:
I F m T H E N statement(s) [ELSE statement(s)]
I F m GOTO line/label
I F m T H E N 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. T HEN 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.
Other wise exec ution continues w ith the next exec utable statem ent.
THE N or ELSE may be fo llowed by e ither a line nu mber for br anching, or one or mor e statemen ts
to be executed. IF/ THE N/E LSE statements may be nested.
10 IF A=B THEN C=2 ELSE IF A=J THEN PRINT J
If an IF. . THE N 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/labe l does not exist