QBasic 1.1: ON...GOTO Statement

Syntax

ON expression% GOSUB line-list
ON expression% GOTO line-list

Description / Parameter(s)

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