IBM Version 4 Universal Remote User Manual


 
COPY QUSEC OF QSYSINC-QCBLLESRC.
ᑍ Miscellaneous elements
1 MISC.
5 Y PIC S9(9) VALUE .
1 ERROR-HANDLER PROCEDURE-POINTER.
1 OLD-ERROR-HANDLER PROCEDURE-POINTER.
1 NUMERIC-GROUP.
5 X PIC 9(3).
ᑍ Beginning of mainline
PROCEDURE DIVISION.
MAIN-LINE.
ᑍ Register the COBOL Error Handler.
ᑍ Initialize the error code parameter. To signal exceptions to
ᑍ this program by the API, you need to set the bytes provided
ᑍ field of the error code to zero. Because this program has
ᑍ exceptions sent back through the error code parameter, it sets
ᑍ the bytes provided field to the number of bytes it gives the
ᑍ API for the parameter.
MOVE 16 TO BYTES-PROVIDED.
ᑍ Set ERROR-HANDLER procedure pointer to entry point of
ᑍ ERRHDL1 ᑍPGM
SET ERROR-HANDLER TO ENTRY LINKAGE PROGRAM "ERRHDL2".
ᑍ Call the API to register the exit point.
CALL "QlnSetCobolErrorHandler" USING ERROR-HANDLER,
OLD-ERROR-HANDLER,
QUS-EC.
ᑍ If an exception occurs, the API returns the exception in the
ᑍ error code parameter. The bytes available field is set to
ᑍ zero if no exception occurs and greater than zero if an
ᑍ exception does occur.
IF BYTES-AVAILABLE > 
DISPLAY "Error setting handler",
STOP RUN.
ᑍ If the call to register an error handler is successful, then
ᑍ cause a the data decimal error (X is initialized to blanks).
ADD X TO Y.
ᑍ Should not get here due to data decimal error
STOP RUN.
ᑍ End of MAINLINE
Appendix B. Original Examples in Additional Languages B-123