6 Branching and Subroutines
* 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 ENDThe 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: