statement/ON statement/ON NAME ON -- Redirects program execution conditionally ABBREVIATION None SYNOPSIS ON <expression> GOSUB <line>[,<...>,<line>] ON <expression> GOTO <line>[,<...>,<line>] FUNCTION This command can make the GOTO and GOSUB statements into special versions of the IF statement. The word ON is followed by a formula, then either GOTO or GOSUB, and a list of line numbers separated by commas. If the result of the calculation of the formula (<expression>) is 1, the first line (<line>) in the list is executed. If the result is 2, the second line number is executed, and so on. If the result is 0, or larger than the number of line numbers in the list, the next line executed is the statement following the ON statements. If the number is negative, an ILLEGAL QUANTITY ERROR results. INPUTS <expression> - BASIC expression resulting a numeric value <line> - line number where program execution should continue RESULT Program execution continues at the line chosen from the line number list according to a value determined by a BASIC expression (<expression>). EXAMPLES 10 INPUT X:IF X<0 THEN 10 20 ON X GOTO 50, 30, 30, 70 25 PRINT "FELL THROUGH":GOTO 10 30 PRINT "TOO HIGH":GOTO 10 50 PRINT "TOO LOW":GOTO 10 70 END When X = 1, ON sends control to the first line number in the list (50). When X = 2, ON sends control to the second line (30), etc. NOTES None BUGS None SEE ALSO GOSUB GOTO IF