Exceptions
9.0C
Beginning with version 9.0.C of the Windows and Linux runtimes, a new capability has been added to the PL/B language to capture exception program events. The exception program events are similiar to the trappable program events except that the target exception routine is executed using a GOTO as opposed to a CALL. Six new instructions support the exception program events. The new instructions are named EXCEPTCHECK, EXCEPTCLEAR, EXCEPTDISABLE, EXCEPTDO, EXCEPTENABLE, and EXCEPTSET. Note the following regarding exception program event support:
The exception program events must be used to capture events that occur within the scope of a (L)FUNCTION subroutine.
The exception program Events that can be captured are separated into two groups. Group 1 includes IO, CFAIL, DBFAIL, FORMAT, RANGE, PARITY, SPOOL, INTERRUPT (INT), OBJECT, and USER events. Group 2 includes ESCAPE, {char}, BACKSPACE and CANCEL characters, Function Flags (F1 - F40, UP, DOWN, LEFT, RIGHT, INS, DEL, HOME, PGUP, PGDN, END, ESCAPE (ESC), TAB, BACKTAB, and FKEY), and EVENT.
There is a special exception program Event named USER that allows a user PL/B program to generate user program events. The USER event can only be generated using the EXCEPTDO instruction.
The exception program event states are saved and restored at every call/return stack level used in a program. An exception program event stack has been implemented to support this functionality.
With group 1 events:
The EXCEPTSET instruction enables an exception program event at the current call/return stack level.
When a CALL instruction is executed, all of the current exception program event states are saved as defined before the CALL. The user program can optionally use the EXCEPTSET to set new exception program events in the subroutine that has been called to override any previous event that has been previously enabled.
If the user program does not use EXCEPTSET to override a previously enabled event, detection of a exception program event for group1 causes the CALL/RETURN stack to unwind to the stack level where the enabled exception program can be captured.
When a RETURN instruction is executed, all of the exception program events are automatically restored back to saved states that existed prior to the CALL instruction.
With group 2 events:
The EXCEPTSET instruction enables an exception program event at the current call stack level.
When a CALL instruction is executed, all of the current exception program event states are saved as defined before the CALL. Next, all of the exception program events for group 2 are cleared. The user program must execute an EXCEPTSET instruction to establish the event capture routines at the new call stack level. Note that when using the exception program group 2 events, No call stack unwind actions are executed.
When a RETURN instruction is executed, all of the exception program events are automatically restored back to saved states that existed prior to the CALL instruction.
If a TRAP event is set and the same exception program event is set in a program, the exception program event operation takes precedence and is executed.
See Also: EXCEPTCHECK, EXCEPTCLEAR, EXCEPTDISABLE, EXCEPTDO, EXCEPTENABLE, EXCEPTSET, Trappable Events, Program Control Instructions
![]() |