4-233
Detailed explanation of command words
4MELFA-BASIC IV
On ... GoTo (On Go To)
[Function]
Branches to the step with the step label that corresponds to the designated value.
[Format]
[Terminology]
<Expression>
Designate the step label on the line to branch to with a numeric operation expression.
<Call Destination> Describe the step label No. The maximum number is 32.
[Reference Program]
Branches based on the value (1-7) of the numerical variable M1.
(Branches to step 20 if M1 is 1, to label LJMP if M1 is 2, to step 50 if M1 is 3, 4 or 5, and to label L67 if M1
is 6 or 7.)
10 On M1 GoTo L1,*LJMP,*L2,*L2,*L2,*L67,*L67
11 ' Control is passed to this line when M1 is other than 1 through 7 (i.e., 0, or 8 or larger).
20 *L1
21 ' Describes processing when M1=1.
22 ' :
30 *LJMP
' When M1=2.
31 ' Describes processing when M1=2.
32 ' :
40 *L67
41 ' Describes processing when M1=6 or M1=7.
42 ' :
50 *L2
51 ' Describes processing when M1=3, M1=4, or M1=5.
52 ' :
[Explanation]
(1) This is the GoTo version of On GoSub.
(2) If the value of <expression> is larger than the number of <destinations called up>, the program control
jumps to the next step. For example, the program control jumps to the next step if the value of <expres-
sion> is 5 and there are only three <destinations called up>.
(3) When a step No. or label that is called up does not exist, or when there are two definitions, an error will
occur.
On[]<Expression>[]GoTo[][<Branch Destination>] [, [<Branch Destination>]] ...
Value of <Expression>
Process <Control>
Real number
Value is converted to an integer by rounding it off,
and then branching is executed.
When 0, or when the value exceeds the num-
ber of step labels
Control proceeds to the next step
Negative number or 32767 is exceeded
Execution error