HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


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.

END-DISPLAY Difference

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.


VAX Results


               B1 =  -1
               B2 =  -1


Alpha and I64 Results


               B1 =  65535
               B2 =  65535


B.4.4.4 SEARCH Statement

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:

  • HP COBOL on Alpha and I64 does not perform the same run-time error recovery behavior as HP COBOL on VAX upon receipt of the following diagnostic:


    %COBOL-E-EXITDECL, EXIT PROGRAM statement invalid in GLOBAL DECLARATIVE
    
  • HP COBOL on VAX always ignores an EXIT PROGRAM in a GLOBAL USE procedure. HP COBOL on Alpha and I64 ignores the EXIT PROGRAM only if the GLOBAL USE is invoked from other than the current program unit.
    To produce behavior identical to HP COBOL for OpenVMS VAX, correct the problem causing the diagnostic.
  • If one of the operands in a comparison is illegal, causing an error message, HP COBOL on VAX continues analyzing the statement containing the conditional, but HP COBOL on Alpha and I64 skips to the next statement (thus not finding any additional errors in the statement).
  • If a source statement contains multiple divides and the divisor(s) are a literal zero, a figurative zero, or a variable whose value is zero, HP COBOL on Alpha and I64 issues a single divide-by-zero run-time diagnostic, while HP COBOL on VAX issues the same diagnostic for each divide-by-zero in the statement. For example, the following code produces three diagnostics with HP COBOL on VAX and only one diagnostic with HP COBOL on Alpha and I64:


    DIVIDE 0 INTO A, B, C.
    

    In accordance with the ANSI COBOL Standard, both compilers allow execution to continue with unpredictable results.
  • The HP COBOL RTL on Tru64 UNIX can give a result that differs from OpenVMS Alpha and OpenVMS I64 in the case where your program tries to create an ISAM file with two keys that are the same except for the status of the duplicates (one key specifies DUPLICATES and the other key does not). In this case, on Tru64 UNIX you will receive the following message (if -rkc is not specified):


     COB_S_ISAM_BADKEY
     ISAM file %s created with two keys that are the same except for
     their acceptance of duplicate values
    

    This will be translated into the COBOL status code 39, which is used for a conflict in file attributes.
    HP COBOL on OpenVMS Alpha and HP COBOL on OpenVMS I64 do not allow duplicate keys unless directed in both key specifications.
  • There is a difference between HP COBOL on VAX and HP COBOL on Alpha and I64 in the enforcement of the general rule that name conflicts should be avoided, including names used for COPY libraries. On VAX, the compiler does not enforce this rule in some cases, including COPY and PROGRAM-ID. Hence a COBOL program that compiles without error on VAX might result in a NAMCLASS error on Alpha and I64, as follows:


    Previous Next Contents Index