TRAP Examples
Example 1:
|
|
|
|
|
|
|
|
The TRAP instruction indicates that the program should CALL the subroutine NOMASTER if an IO error occurs. If the OPEN instruction fails because the file does not exist, an IO error occurs and the program calls NOMASTER.
Example 2:
|
|
|
|
|
|
|
|
The TRAP instruction indicates that the program should CALL the subroutine NOPROGRM if a CFAIL error occurs. If the CHAIN instruction fails (program does not exist, is a bad load module or insufficient system resources), a CFAIL error occurs and the program calls NOPROGRM. The trap remains set (NORESET) until a new TRAP CFAIL is set, a TRAPCLR CFAIL occurs or the program terminates.
Example 3:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The TRAP instruction indicates that the program should CALL the subroutine HELP if an F1 function key is pressed during the KEYIN instruction. The PRIOR option causes the RETURN instruction in the HELP subroutine to return to the KEYIN instruction instead of the instruction after the KEYIN instruction. Note that the PRIOR option on TRAP is only active during a KEYIN instruction.
Example 4:
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The TRAP instruction indicates that the program should CALL the subroutine GETTIME when sixty seconds has expired. The GETTIME routine retrieves the current system time. It then saves the current display state, outputs the time and then restores the display state. Finally, the routine resets the timer trap and returns.
![]() |