Trappable Events


 

The following program events are trappable: IO, CFAIL, DBFAIL, FORMAT, RANGE, PARITY, SPOOL, INTERRUPT (INT), ESCAPE, {char}, MOUSE, the BACKSPACE and CANCEL characters, plus any of the Function Flags (F1 - F40, UP, DOWN, TAB, BACKTAB, etc.) and the catch-all Function Flag FKEY. The EVENT and OBJECT program events are also trappable when operating with PLBCMP in a GUI environment. The event TIMER is only available when using the SUNDBSYS runtime.

Note the following:

  1. 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.

  2. The event IO indicates a disk I/O error has occurred. This event is useful in testing whether a disk file already exists or not. Trying to OPEN a non-existent file causes an IO error.

  3. The event CFAIL indicates an error occurred while attempting to CHAIN to another program. This usually only occurs if the program being CHAINed to does not exist as specified, was an invalid format (bad load module) or there is insufficient system resources to load it.

  4. The event DBFAIL indicates an error occurred while attempting to access an ODBC database using one of the SQL instructions.

  5. The event FORMAT indicates an attempt was made to READ non-numeric data into a numeric variable. The READ stops at the list item in error without changing the remaining list items.

  6. The event RANGE indicates a record number was out of range. This generally occurs only when an attempt is made to read a sector that has not yet been written.

  7. The event PARITY indicates a disk CRC error occurred during a READ or during the verification after a WRITE.

  8. The event SPOOL indicates an error occurred during an attempt to route the print output to the designated or default printer device or file. This type of error may occur if the spool file or device is already in use by another terminal (i.e., a lock has been placed on it), if there is insufficient access rights to the device or file, if the disk is out of space or other such disk errors.

  9. The event INTERRUPT (INT) indicates the operating system interrupt sequence was entered.

  10. The event ESCAPE indicates the ESCAPE (ESC) key was struck. Due to the lack of sub-second support by some Linux and compatible operating systems, the TRAP for ESCAPE may take up to one second after actual depression of the key.

  11. The event {char} or CHAR {char} indicates the specified character was entered. {char} may be a one byte literal or variable from octal 0 to octal 377. When the CHAR {char} form is used, {char} may be specified as an equated value, decimal constant, hex constant, or octal constant. If a variable is used, the form pointed character at the time the TRAP instruction is issued is used. Multiple {char} traps may be used of the ANSI compilation mode is specified for the compiler. Otherwise, setting a {char} trap clears the previous {char} trap.

  12. The event MOUSE indicates that one of the buttons on the mouse was tapped. The NORESET clause is invalid with this event. This event is only valid with SUNDB86x.

  13. The Function Flags event indicates that a specified function or special key was entered. Any function key defined within the screen definition file in use, up to the supported maximum of 40, may be trapped. It is even possible to set a different TRAP for each function key. In addition, any special key defined within the screen definition file in use (UP, DOWN, LEFT, RIGHT, INS, DEL, PGUP, PGDN, HOME, or END) may have a TRAP set for each.

  14. The event FKEY indicates a previously untested function key, special key or the ESCAPE key was entered. FKEY only supports those keys defined within the screen definition file in use.

  15. An EVENT trap is taken if an object event occurs. The EVENT trap is only available with PLBCMP when operating in a GUI environment.

  16. An OBJECT trap is taken if an error occurs in an object instruction. The OBJECT trap is only available with PLBCMP when operating in a GUI environment.

  17. A TIMER trap is taken when the specified time interval has expired. The TIMER trap is only available with the SUNDBSYS runtime.

  18. When executing a PL/B program using a GUI runtime, the keyboard events for the TRAP instruction including CHAR {char], F1-F40, FKEY, ESCAPE, and the special keys are only processed for KEYIN instructions. This means that the keyboard traps are only processed for the MAINWINDOW since it is the only WINDOW that supports the KEYIN instructions. Also, the keyboard event TRAPs do not get dispatched unless the MAINWINDOW has the focus to accept the Windows key stroke messages.

 

 

See Also: TRAP, Exceptions, Program Control Instructions

 



PL/B Language Reference Functions BRANCH