Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
ON...GOSUB, ON...GOTO Statements
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Branch to one of several locations, depending on the value of an expression.
ON expression% GOSUB line-list
ON expression% GOTO line-list
■ expression% An expression in the range 0 through 255.
■ line-list A set of labels or line numbers. If the value of the
expression is 1, the program branches to the first line
in the list; if the expression is 2, it branches to the
second line, and so on.
■ SELECT CASE provides a better way to perform multiple branching.
Example:
FOR i% = 1 TO 2
ON i% GOSUB One, Two
NEXT i%
END
One: PRINT "One"
RETURN
Two: PRINT "Two"
RETURN
See Also ◄ON Keyword► ◄SELECT CASE►