ON GOTO
Conditional GOTO
This directive unconditionally branches to one of a series of program line numbers or labels, depending on the value of a numeric expression.
Syntax
Section titled “Syntax”ON numeric-value GOTO line-ref0 [,line-ref1 [,line-ref2...line-ref-n]]numeric-value- is an integer.
line-ref0- is the program line number or label to branch to if numeric-value is less than 1 (negative or 0).
line-ref1- is the program line number or label to branch to if numeric-value is equal to 1.
line-ref2- is the program line number or label to branch to if numeric-value is equal to 2.
line-ref-n- is the program line number or label to branch to if numeric-value is equal to or greater than n.
Remarks
Section titled “Remarks”This directive cannot be used in Thoroughbred Basic Console Mode.
If numeric-value is not an integer, an ERR=41 results.
The first line-ref listed is targeted if numeric-value is 0 or less, the second line-ref is targeted if numeric-value is 1, and so on with the last line-ref targeted for all remaining values of numeric-value.
Examples
Section titled “Examples”ON OUTCOME_OF_THOUGHT GOTO 100,200,300If OUTCOME_OF_THOUGHT < 0 then execute statement 100.
If OUTCOME_OF_THOUGHT = 0 then execute statement 100.
If OUTCOME_OF_THOUGHT = 1 then execute statement 200.
If OUTCOME_OF_THOUGHT = 2 then execute statement 300.
If OUTCOME_OF_THOUGHT > 2 then execute statement 300.
See also
Section titled “See also”GOTO directive
From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF