36
CipherLab BASIC Programming Part I
ON … GOTO …
Purpose
To branch to one of several specified Line Labels depending on the value of an
expression.
Syntax ON N GOTO LineLabel {, LineLabel}
Remarks “N” is a numeric expression which is rounded to an integer. The value of N
determines which line label in the list will be used for branching. If the value N
is 0, or greater than the number of line labels listed, the interpreter will
continue with the next executable statement.
“LineLabel” is the string label of a program line.
Example
PRINT “Input a number (1-9):”
INPUT Num%
CLS
ON Num% GOTO 100, 100, 200, 200, 300, 400, 400, 400
…
100
PRINT “Number 1-3 is input.”
GOTO 500
200
PRINT “Number 4-5 is input.”
GOTO 500
300
PRINT “6 is input.”
GOTO 500
400
PRINT “Number 7-9 is input.”
500