on gosub - branch to subroutine based on expression
on NumExpr gosub LineNum[, LineNum] . . .
on NumExpr gosub LineLab[, LineLab] . . .
statement transfers control to one of several subroutines
based on the value of a numerical index,
supplied by the NumExpr argument.
NumExpr must be a numeric value and if it is not an integer,
it is rounded to integer before use as the index.
The LineNum and LineLab arguments are assumed to be the starting line numbers
of one or more subroutines. LineNum and LineLab arguments may be mixed in the
The value of the index selects a LineNum or LineLab argument to which to
transfer control based on direct correspondence between the index
value and the position of the arguments in the list.
An index value of 1 selects the first argument, 2 the second,
and so on.
statement is executed by the subroutine selected,
execution resumes at the statement following the
If the value of NumExpr is zero or greater than the number of items in
the list, no transfer occurs and BASIC continues with the
next executable statement.
statement in line 100, a branch to line 100 occurs if x equals 1,
to line 200 if x equals 2,
to line 300 if x equals 3, and to line 400 if x equals 4.
x is equal to 0 (zero) or is greater than 4, then the program just goes
on to the next statement.
a = 1
on a gosub 100, 200, 300, 400
100 rem start of subroutine for a=1
gosub, goto, on goto
If NumExpr is negative, an "Illegal function call" error occurs.
The Basmark QuickBASIC Programmerís Manual