Appendix B. Differences Among the COBOL Standards

The following are some major additions to COBOL that were incorporated in the COBOL 85 standard and that we have discussed in the text. This list does not include every change from COBOL 74, just the more significant ones.

  1. Scope Terminators

    Use the following terminators to produce a more well-designed program:

    END-ADD               END-MULTIPLY               END-START
    END-COMPUTE           END-PERFORM                END-STRING
    END-DELETE            END-READ                   END-SUBTRACT
    END-DIVIDE            END-RETURN                 END-UNSTRING
    END-EVALUATE          END-REWRITE                END-WRITE
    END-IF                END-SEARCH

    Examples

    1. IF AMT1 = AMT2
         READ FILE-1
            AT END MOVE 'NO ' TO ARE-THERE-MORE-RECORDS
         END-READ
      END-IF
    2. IF AMT1 = AMT2
         ADD AMT1 TO TOTAL
             ON SIZE ERROR PERFORM 200-ERR-RTN
         END-ADD
      END-IF
  2. The reserved word THEN may be used in a conditional, which makes COBOL conform more specifically to an IF-THEN-ELSE structure.

    Example

    IF AMT1 < 0
    THEN
        ADD 1 TO CTR1
    ELSE
       ADD 1 TO CTR2
    END-IF
  3. INITIALIZE Verb

    A series of elementary items contained within a group item can all be initialized with this verb. Numeric items will be initialized at zero, and nonnumeric items will be initialized with blanks.

    01 WS-REC-1.
       05         PIC X(20).
       05 NAME    PIC X(20).
       05         PIC X(15).
       05 AMT-1   PIC 9(5)V99.
       05         PIC X(15).
       05 AMT-2   PIC 9(5)V99.
       05         PIC X(15).
       05 TOTAL   PIC 9(6)V99.
       05         PIC X(13).
       .
       .
       .
       INITIALIZE WS-REC-1

    The above will set AMT-1, AMT-2, and TOTAL to zeros and will set all the other fields to spaces.

  4. An in-line PERFORM is permitted, making COBOL more like pseudocode.

    Example

    PERFORM ADD AMT1 TO TOTAL ...

Get COBOL for the 21st Century now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.