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
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......