32
CipherLab BASIC Programming Part I
4.2 COMMANDS FOR DECISION STRUCTURES
Based on the value of an expression, decision structures cause a program to take one of
the following two actions:
To execute one of several alternative statements within the decision structure itself.
To branch to another part of the program outside the decision structure.
In CipherLab BASIC, decision-making is handled by the IF…THEN…[ELSE…][ENDIF]
and ON…GOSUB|GOTO… statement. The IF…THEN…[ELSE…][ENDIF] statement
can be used anywhere the ON…GOSUB|GOTO… statement can be used. The major
difference between the two statements is that ON…GOSUB|GOTO… evaluates a single
expression, and then executes different statements or branches to different parts of the
program based on the result. On the contrary, a block IF…THEN…[ELSE…][ENDIF]
can evaluate completely different expressions.
Moreover, the expression given in the ON expression GOSUB|GOTO… statement must
be evaluated by a number in the range 1 to 255, while the expression in
IF…THEN…[ELSE…][ENDIF] statement can only be evaluated as a TRUE or FALSE
condition.
The IF…THEN…[ELSE…][ENDIF] statement can be nested up to 10 levels.