Compaq COBOL AAQ2G1FTK User Manual

Page 476

Advertising
background image

Using Compaq COBOL in the Alpha Common Language Environment
13.4 Calling Routines

For example:

01 SS$_NORMAL PIC S9(5) COMP VALUE EXTERNAL SS$_NORMAL

.
.
.
CALL "LIB$STAT_TIMER" USING ARG-CODE, ARG-VALUE GIVING RET-STATUS.
IF RET-STATUS NOT EQUAL SS$_NORMAL...

Because all success codes have odd values, you can check a return status for any
success code. For example, you can cause execution to continue only if a success
code is returned by including the following statement in your program:

IF RET-STATUS IS SUCCESS ...

Sometimes several success condition values are possible. You may only want to
continue execution on specific success codes.

For example, the $SETEF system service returns one of two success values:
SS$_WASSET or SS$_WASCLR. If you want to continue only when the success
code SS$_WASSET is returned, you can check for this condition value as follows
and branch accordingly:

IF RET-STATUS EQUAL SS$_WASSET ...

or

EVALUATE RET-STATUS

WHEN SS$_WASSET ...

If the condition value returned is not a success condition, then the routine did not
complete normally, and the information it should have returned may be missing,
incomplete, or incorrect.

You can also check for specific error conditions as follows:

WORKING-STORAGE SECTION.
01 USER-LINE

PIC X(30).

01 PROMPT-STR

PIC X(16) VALUE IS "Type Your Name".

01 OUT-LEN

PIC S9(4) USAGE IS COMP.

01 COND-VALUE

PIC S9(9) USAGE IS COMP.

88 LIB$_INPSTRTRU VALUE IS EXTERNAL LIB$_INPSTRTRU.

.
.
.

PROCEDURE DIVISION.
P0.

CALL "LIB$GET_INPUT" USING BY DESCRIPTOR USER-LINE PROMPT-STR

BY REFERENCE OUT-LEN
GIVING COND-VALUE.

EVALUATE TRUE

WHEN LIB$_INPSTRTRU

DISPLAY "User name too long"

WHEN COND-VALUE IS FAILURE

DISPLAY "More serious error".

.
.
.

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

Advertising