ON GOTO/GOSUB Verbs
Syntax
ON int GOTO lineref{,lineref...}
ON int GOSUB lineref{,lineref...}
Description
The ON statement provides a GOTO or a GOSUB with several possible branch destinations.
| Parameter | Description |
|---|---|
|
int |
Branch destination. If |
|
lineref |
Branch destination line number. |
For example, if the code states the following and the value of A is 6, the program branches to line 5000.
2010 ON A GOTO 3000,4000,5000
The GOTO or GOSUB statements are executed exactly like normal GOTO or GOSUB statements, and the same line number can appear more than once in the list. However, ON GOSUB cannot be used in console mode. In a compound statement, only ELSE, FI, or REM can follow ON GOTO.
Examples
1000 ON A GOTO 1100,1200,1300
1000 ON B GOSUB 2100,2200,2200,2300