Used with permission, from the CLIST & rexx place.
Using END-IF and minimizing period usage makes for much more maintainable code. In my opinion END-IF was the most important innovation made to Cobol in the 30 years I've been in this business.
I keep thinking of this since Don mentioned it (well, not all the time, so stop giggling about it at the back there). I think he is right. Certainly the feature I used most often.
IF (A EQUAL TO B)
PERFORM STUFF-TO-DO-IN-THIS-INSTANCE. (only an eg guys)
MOVE C TO D.
MOVE E TO F.
MOVE G TO H.
Now, someone would need to make the three moves conditional. Shift to the right for the indent, take the periods off the first two. Compile, run. Mmm... what's gone wrong? Period still on the perform. Or leave one of the periods on one of the moves. Too easy to do if being sloppy, but what can you do about it?
IF (A EQUAL TO B)
MOVE C TO D
MOVE E TO F
MOVE G TO H
Gone were the days of "End of sentence not preceded by period, period assumed" with the advent of COBOL II. Move the code inside the IF, change the indenting. Bobs your uncle.
Problem was, you could still use periods if you wanted. Still works reasonably well, as the compiler spots the END-IF, now without an IF.
Worse problem. You didn't need to code the END-IF. A period would do.
Simple question after the build-up, two-stage answer. What is the most important change from "old" Cobol until today 1) to aid the production of maintainable code 2) for any other reason you like?
I'm sticking with Don on 1), unless convinced otherwise. For 2) I'm considering Web support as a strategic answer.
Follow-on question. I have more topics if you like. However, I don't want to be a bore. If you don't like these, can you form an orderly queue over by the fire exit?
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
Here's a short laundry list -
Along the same lines as END-IF, there's always in-line PERFORM (default TEST BEFORE), which is akin to a PL/I DO WHILE (may not execute at all). TEST AFTER is akin to PL/I DO UNTIL (will execute at least once). Both introduced with VS/COBOL II.
Reference Modification (a major improvement). Introduced with VS/COBOL II.
HEX notation. Introduced with VS/COBOL II.
Easy handling of variable length files in Batch (many posts on the forum about this subject). Introduced with VS/COBOL II.
INSPECT WITH LITERALS (Resolves in-line as a single TR instruction). Introduced with VS/COBOL II.
COBOL FUNCTIONS (Introduced with COBOL/370, the successor to VS COBOL II).
PROCEDURE POINTER (load an external program/table into memory - similar to an MVS LOAD Macro). Introduced with COBOL/370.
Language Environment integration (introduced with COBOL/370 as well).
COMP-5 Binary (Introduced with OS/390 COBOL 2.2.1). TRUNC option has NO EFFECT. Also known as Native Binary.