B–2 Illegal Return Value Coding - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration
B.4 Compaq COBOL and Compaq COBOL for OpenVMS VAX Behavior Differences
The bad coding practice exhibited in Example B–2 can impact OpenVMS Alpha,
Windows NT, and Tru64 UNIX systems, and any supported Alpha floating-point
data type.
Example B–2 Illegal Return Value Coding
IDENTIFICATION DIVISION.
PROGRAM-ID. BADCODING.
ENVIRONMENT DIVISION.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
PROCEDURE DIVISION USING PARM-REC GIVING CMR-RETURN-CODE.
P0-CONTROL.
P0-EXIT.
In Example B–2 the programmer incorrectly defined the return value for a
system service call to be F_floating when it should have been binary (COMP).
The programmer was depending on the following VAX behavior: in the VAX
architecture, all return values from routines are returned in register R0. The
VAX architecture has no separate integer and floating-point registers. The Alpha
architecture defines separate register sets for floating-point and binary data.
Routines that return floating-point values return them in register F0; routines
that return binary values return them in register R0.
Compaq COBOL for OpenVMS VAX and Compaq COBOL Compatibility and Migration B–19
01 FIELDS-NEEDED.
05 CYCLE-LOGICAL
01 EDIT-PARM.
05 EDIT-YR
05 EDIT-MO
01 CMR-RETURN-CODE
01 PARM-REC.
05 CYCLE-PARM
05 MY-RETURN-CODE
CALL 'LIB$SYS_TRNLOG' USING BY DESCRIPTOR CYCLE-LOGICAL,
IF MY-RETURN-CODE GREATER 0
THEN
MOVE MY-RETURN-CODE TO CMR-RETURN-CODE
GO TO P0-EXIT.
MOVE CYCLE-PARM TO EDIT-PARM.
IF EDIT-YR NOT NUMERIC
THEN
MOVE 4 TO CMR-RETURN-CODE, MY-RETURN-CODE.
IF EDIT-MO NOT NUMERIC
THEN
MOVE 4 TO CMR-RETURN-CODE, MY-RETURN-CODE.
IF CMR-RETURN-CODE GREATER 0
OR
MY-RETURN-CODE GREATER 0
THEN
DISPLAY "***************************"
DISPLAY "** BADCODING.COB **"
DISPLAY "** A_LOGICAL_NAME> ", CYCLE-PARM, "
DISPLAY "***************************".
EXIT PROGRAM.
PIC X(14) VALUE 'A_LOGICAL_NAME'.
PIC X(4).
PIC XX.
COMP-1 VALUE 0.
PIC X(6).
COMP-1 VALUE 0.
OMITTED,
BY DESCRIPTOR CYCLE-PARM
GIVING MY-RETURN-CODE.
**"

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents