HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4- 92
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_id
s, or an error occurs if no ELSE
clause is present. Control is transferred to the
n
th
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_id
s 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
ON HALT
The ON HALT statement specifies an action that the program executes when
it traps pressing of the halt key.
If an ON HALT statement is active when the halt key is pressed, the ON
HALT Statement traps the halt key, and the ON HALT directive (GOTO, GOSUB
or CALL) is executed. The program is not suspended as it is when no ON
HALT statement is present in the program.
Syntax
{GOTO }
[{GO TO } ]
ON HALT [{GOSUB }
line_id
]
[{GO SUB} ]
[CALL
sub_id
]
Parameters
line_id
Line label or line number. Control will transfer to
this
line_id
when the ON HALT statement executes.
sub_id
Subunit identifier. Control will transfer to this
subunit when the ON HALT statement executes.
Table 4-9 shows the similarities and differences between the three forms
of the ON HALT statement.