1985 COBOL standard is commonly referred to as COBOL85. It's still COBOL
, but with some added functionality to make life easier. COBOL85 introduced scope terminators, data field referencing, and the
Scope terminators allow a programmer to write more legible code, and do certain things that were not possible before COBOL85.
Example 1: The inline PERFORM
PERFORM UNTIL (NO-MORE-DATA)
is key here, since it tells the program
where the loop ends. There was no
prior to COBOL85.
Example 2: The Nested IF
IF (DATA-RECORD = SPACES)
ADD 1 TO BLANK-CNT
IF (DATA-RECORD = ZEROS)
ADD 1 TO ZERO-CNT
ADD 1 TO RECORD-CNT
makes the code more readable, and allows for a bit more coding flexibility.
I won't bore you with the others (there are at least 10), but you can get the idea of what a scope terminator is used for.
Data field referencing allows portions of a field to be manipulated or checked for values. This is useful if a field has a value you want to extract.
contains PA: Marysville. If you wanted to extract PA, you would do that by using a
statement as follows:
MOVE TEXT-LINE (1:2) TO TEXT-STATE
portion is telling the program to move everything from position 1 and 2 to the field
The last big change is the addition of the
statement. Using this statement
eliminates the need for a complex
IF block in some instances.
Example 1: Range
Example 2: Explicit Values
WHEN 01 THRU 12
WHEN 01 THRU 17
MOVE "NON-ADULT" TO AGE-TEXT
MOVE "ADULT - UNDER DRINKING AGE" TO AGE-TEXT
WHEN 21 THRU 99
MOVE "ADULT - DRINKING AGE" TO AGE-TEXT
Example 1 shows an evaluation
of a range of values. Example 2 shows the same as Example 1, except it is also checking for an explicit value: 18.
COBOL isn't dead just yet.