51
ON GOTO
PURPOSE
: Jumps to a specified branch destination in accordance with a specified
branching condition.
FORMAT
:
branch destination line number
Line number
ON
Condition
GOTO
[
# program area number
]
Numeric expression
Single character; 0-9
*Label
Label name
branch destination line number
Line number
[ , [
# program area number
] ]*
Single character; 0-9
*Label
Label name
EXAMPLE
: ON A GOTO 100, 200, 300
PARAMETERS
:
1. Branch condition: Numeric expression truncated to an integer
2. Branch destination line number: integer in the range of 1
≤
line number
≤
65535
3. Program area number: single character, 0-9
4. Label: Name of a label in the program.
EXPLANATION
:
1. The GOTO statement is executed in accordance with the value of the
expression used for the branch condition. For example, execution jumps to the
first branch destination when the value is 1, to the second destination when
the value is 2 etc.
2. Program execution does not branch and execution proceeds to the next
statement when the value of the condition is less than 1, or if a branch
destination corresponding to the value does not exist.
3. Up to 99 branch destinations may be specified.
SAMPLE PROGRAM:
10 INPUT “1 OR 23;A
20 ON A GOTO 40,50
30 END
40 PRINT ”ONE”:END
50 PRINT “TWO”
Execution jumps to line 40 if 1
.
.
is entered or to line 50 if 2
.
.
is entered.
SEE
: ON GOSUB
P
0