HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
If you attempt to use extended ACCEPT/DISPLAY with input redirected from a file or output redirected to a file, the operation differs between HP COBOL on VAX and HP COBOL on Alpha and I64. In general, on Alpha and I64, the HP COBOL RTL attempts to use ANSI ACCEPT/DISPLAY to handle all ACCEPT and DISPLAY statements in this situation. For example, if you use DISPLAY AT LINE or ACCEPT DEFAULT, the RTL will ignore the extensions (that is, LINE or DEFAULT) if you redirect output to a file or input from a file. On VAX, the RTL ignores some, but not all, ACCEPT/DISPLAY extensions when input is redirected from a file or output is redirected to a file.
In HP COBOL on Alpha and I64, a DISPLAY statement in an ON EXCEPTION for an ACCEPT statement must be terminated, with, for example, END-DISPLAY. END-DISPLAY is supported for all formats of DISPLAY on Alpha and I64.
In HP COBOL on VAX, END-DISPLAY is not supported. If you convert code with ACCEPT ON EXCEPTION to handle DISPLAY on VAX and also on Alpha and I64, you need to PERFORM a paragraph with the DISPLAY from the ON EXCEPTION processing in the ACCEPT.
For more information about ACCEPT and DISPLAY, including sample
programs, see Chapter 11, Using ACCEPT and DISPLAY Statements for Input/Output and Video Forms.
B.4.4.2 LINAGE Clause
HP COBOL on Alpha and I64 and HP COBOL on VAX exhibit
different behavior when handling large values for the LINAGE clause. If
the line count for the ADVANCING clause of the WRITE statement is
larger than 127, HP COBOL on Alpha and I64 advances one line,
whereas VAX results are undefined.
B.4.4.3 MOVE Statement
Unsigned computational fields can hold larger values than signed computational fields. In accordance with the ANSI COBOL Standard, the values for unsigned items should always be treated as positive. HP COBOL on VAX, however, treats unsigned items as signed, while HP COBOL on Alpha and I64 treats them as positive. Therefore, in some rare cases, a mixture of unsigned and signed data items in MOVE or arithmetic statements can produce different results between HP COBOL on VAX and HP COBOL on Alpha and I64.
Example B-1 produces different results for HP COBOL for OpenVMS VAX and HP COBOL on Alpha and I64.
Example B-1 Signed and Unsigned Differences |
---|
IDENTIFICATION DIVISION. PROGRAM-ID. SHOW-DIFF. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 A2 PIC 99 COMP. 01 B1 PIC S9(5) COMP. 01 B2 PIC 9(5) COMP. PROCEDURE DIVISION. TEST-1. MOVE 65535 TO A2. MOVE A2 TO B1. DISPLAY B1 WITH CONVERSION. MOVE A2 TO B2. DISPLAY B2 WITH CONVERSION. STOP RUN. |
B1 = -1 B2 = -1 |
B1 = 65535 B2 = 65535 |
In HP COBOL on Alpha and I64 and in HP COBOL on VAX Version
5.0 and higher, the END-SEARCH and NEXT SENTENCE phrases are mutually
incompatible in a SEARCH statement. If you use one, you must not use
the other. This rule, which complies with the ANSI COBOL Standard, does
not apply to VAX COBOL versions earlier than Version 5.0.
B.4.5 System Return Codes
Example B-2 illustrates an illegal coding practice that exhibits different behavior on Alpha and I64 and VAX. The cause is an architectural difference in the register sets between the VAX and Alpha and I64 architectures: on Alpha and I64, there are separate sets of registers for floating-point data types.
The bad coding practice exhibited in Example B-2 can impact OpenVMS Alpha, OpenVMS I64, and Tru64 UNIX systems and any supported Alpha or I64 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. 01 FIELDS-NEEDED. 05 CYCLE-LOGICAL PIC X(14) VALUE 'A_LOGICAL_NAME'. 01 EDIT-PARM. 05 EDIT-YR PIC X(4). 05 EDIT-MO PIC XX. 01 CMR-RETURN-CODE COMP-1 VALUE 0. LINKAGE SECTION. 01 PARM-REC. 05 CYCLE-PARM PIC X(6). 05 MY-RETURN-CODE COMP-1 VALUE 0. PROCEDURE DIVISION USING PARM-REC GIVING CMR-RETURN-CODE. P0-CONTROL. CALL 'LIB$SYS_TRNLOG' USING BY DESCRIPTOR CYCLE-LOGICAL, OMITTED, BY DESCRIPTOR CYCLE-PARM GIVING MY-RETURN-CODE. 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 "***************************". P0-EXIT. EXIT PROGRAM. |
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 and Itanium® architectures define separate register sets for floating-point and binary data. Routines that return floating-point values return them in a register other than R0; routines that return binary values return them in register R0.
The HP COBOL on Alpha and I64 compilers have no method for determining what data type an external routine may return. You must specify the correct data type for the GIVING-VALUE item in the CALL statement. On the Alpha and Itanium® architectures, the generated code is testing a register other than R0 because of the different set of registers used for floating-point data items.
In the sample program, the value in F0 is unpredictable in this code
sequence. In some cases, this coding practice may produce the expected
behavior, but in most cases it will not.
B.4.6 Diagnostic Messages
Several diagnostic messages have different meanings and results depending on the platform, as follows:
%COBOL-E-EXITDECL, EXIT PROGRAM statement invalid in GLOBAL DECLARATIVE |
DIVIDE 0 INTO A, B, C. |
COB_S_ISAM_BADKEY ISAM file %s created with two keys that are the same except for their acceptance of duplicate values |
Previous | Next | Contents | Index |