ON GOTO [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Reference Manual
ON GOTO
The ON GOTO statement transfers control to one of several lines,
depending on the value of a numeric expression. Although the ON GOTO
statement can be input as ON GOTO or ON GO TO, HP Business BASIC/XL
always lists it as ON GOTO.
Syntax
{GOTO }
ON num_expr {GO TO} line_id [, line_id]...[ELSE else_line_id]
Parameters
num_expr A numeric expression that is evaluated and converted to
an integer, n. The integer n must be between one and
the number of line_ids, or an error occurs if no ELSE
clause is present. Control is transferred to the nth
line_id.
line_id A line number or line label of a line to which control
can be transferred. The line specified must be in the
same program unit as the ON GOTO statement.
else_line_id The ELSE clause allows the specification of a line to
which control is transferred if the value of num_expr is
NOT between one and the number of line_ids specified.
Examples
10 I=2
20 ON I GOTO 30,40,50
30 PRINT "I IS 1"
35 GOTO 99
40 PRINT "I IS 2" !Line 20 transfers control here
45 GOTO 99
50 PRINT "I IS 3"
99 END
The GOTO OF statement works exactly the same as the ON GOTO statement.
The following statements are equivalent:
150 ON I GOTO 10,200,ReInit,Quit
150 GOTO I OF 10,200,ReInit,Quit
MPE/iX 5.0 Documentation