6 Branching and Subroutines

The ON HALT Statement

The ON HALT statement sets up a branching condition which will occur if the BREAK key is pressed.

* Parameters cannot be passed between calling program and subprogram.

The branch occurs immediately after the current program line is executed.

Here is an example sequence which checks for the BREAK key and branches to a routine to store the contents of an array in a data file before stopping the program:

10   ON HALT GOTO Stop
 .
 .
240  STOP
250 Stop: ! Save data  exit program.
260    ASSIGN #1 TO "SaveAray"
270    PRINT #1;Array(*)
280    DISP LIN(10);"PROGRAM HALTED"
290    END
The ON HALT condition is cancelled after SCRATCH, STOP, END or RUN. The condition is only active while the program is running after ON HALT is executed and during an INPUT state, but it is temporarily deactivated during a PAUSE.

To cancel any previous ON HALT condition, use the OFF HALT statement:

OFF HALT


Eloquence Language Manual - 19 DEC 2002