HTBasic Help
×
Menu
Index

ON

Transfers control to one of a list of lines.
 
 ON index {GOSUB | GOTO} line [,line...]
 
Usage:
ON Choose GOSUB Placea,Placeb
ON X/2 GOTO 700,800,900
 
Example:           ON.BAS
 
Description:
ON ... GOTO or ON ... GOSUB allows you to perform a multi-way transfer. You can select one of a list of program line numbers by the computed value of a numeric expression. The numeric expression is rounded to an integer value and is used as an index to select one of the line numbers from the list.
 
If the integer value is 1, the first line number is used. If the integer value is 2, the second line number is used and so on. If the index number is less than one or greater than the number of line numbers in the list, an error is generated.
 
If GOSUB is specified, the matching RETURN is to the line following the ON statement.
 
See Also: