Compaq COBOL AAQ2G1FTK User Manual

Page 479

Advertising
background image

Using Compaq COBOL in the Alpha Common Language Environment

13.5 Establishing and Removing User Condition Handlers (OpenVMS)

The condition handler is written as a subprogram that returns a result. The
result indicates whether or not the condition handler handled the exception.
Note that space must be allocated in the LINKAGE SECTION for the signal and
mechanism arrays. The mechanism array always contains five elements, but the
signal array varies according to the number of additional arguments.

When an exception occurs, the user condition handler is invoked first. The
handler checks the error condition to determine if it is one that it can handle
(the LIB$MATCH_COND routine would be useful here if the routine wanted to
check for one of a collection of conditions). If the exception is not handled by
this condition handler, then the default COBOL condition handler is invoked. If
the default COBOL condition handler does not handle the exception, then the
exception is handled by the operating system.

Example 13–1 User-Written Condition Handler

IDENTIFICATION DIVISION.
PROGRAM-ID.

SSCOND.

DATA DIVISION.
WORKING-STORAGE SECTION.

01

SSHANDA

PIC S9(9) COMP

VALUE EXTERNAL SSHAND.

PROCEDURE DIVISION.
BEGIN.
*
*

Establish condition handler
CALL "LIB$ESTABLISH" USING BY VALUE SSHANDA.

*
*

Enable system service failure mode
CALL "SYS$SETSFM" USING BY VALUE 1.

*
*

Generate a bad system service call
CALL "SYS$QIOW" USING BY VALUE 0 0 0 0

0 0 0 0
0 0 0 0.

STOP RUN.

END PROGRAM SSCOND.

IDENTIFICATION DIVISION.
*
PROGRAM-ID.

SSHAND.

*
*

This routine is to be used as a condition handler

*

for system service failures.

*
*

If this routine does not remedy the exception condition, it will

*

return with a value of SS$_RESIGNAL. If the routine does remedy

*

the exception condition, then it should return with a value of

*

SS$_CONTINUE.

*
DATA DIVISION.

(continued on next page)

Using Compaq COBOL in the Alpha Common Language Environment 13–17

Advertising