HP 3000 Manuals

ON HALT [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

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.

          Table 4-9.  ON HALT Statements 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|      Statement Selected      |        Line to Which         |       Scope of ON HALT       |
|                              |    Control is Transferred    |          Statement           |
|                              |      following ON HALT       |                              |
|                              |          processing          |                              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| GOTO line_id                 | None.                        | Program unit that contains   |
|                              |                              | it.                          |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| GOSUB line_id                | Line following the line that | Program unit that contains   |
|                              | was executing when the halt  | it.                          |
|                              | key was pressed.             |                              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| CALL sub_id                  | Line following the line that | Program unit that contains   |
|                              | was executing when the halt  | it and program unit that it  |
|                              | key was pressed.             | calls, until called unit     |
|                              |                              | executes a local ON HALT     |
|                              |                              | statement or an OFF HALT     |
|                              |                              | statement.                   |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

If you use the CALL option, it cannot have parameters.  To achieve the
effect of a CALL with parameters, use the GOSUB form and put the desired
CALL statement at the GOSUB destination.

Examples 

     10 ON HALT GOSUB 20
     20 CALL Sub3 (A,B)     !Control goes here if the halt key is pressed.

An ON HALT statement is deactivated by execution of another ON HALT
statement or by an OFF HALT statement.



MPE/iX 5.0 Documentation