CHAPTER 7 ----- Formatting practices

COBOL has undergone several revisions in the nearly 30 years since it was introduced. One notable one was in 1974 when the ANSI-74 version of COBOL was introduced. As part of this version, the use of the "/" in column 7 was introduced to specify that the compiler was to advance a page when printing the source code. Prior to this, a compiler-directive of "EJECT" was used. The EJECT directive continues to be supported for compatibility reasons.

In addition, COBOL allows several ways to introduce additional spacing into the compiler listing. One can either (1) insert several blank lines into the source code, (2) insert comment lines with a "*" in column 7, or (3) use the compiler-directives "SKIP1", "SKIP2", or "SKIP3". Some early compilers would automatically drop blank lines, therefore, option (1) was not historically recommended. In addition, if the program was being coded onto coding sheets and sent to a keypuncher for punching onto punched cards, any blank lines might not be keyed. Finally, the use of a "*" in column 7 was described as "comment" cards, and since the remainder of the card was blank, some felt that this was a violation of the purpose of a "comment" card. Thus, the various SKIP directives were used in parallel to the EJECT directive.

Now, however, most programs are keyed directly into the computer by the programmer, either using a "programmers workbench" or some text-editing package. Thus, most programmers are working directly with the source code as well as the program listing from the compiler. This gives us two reasons to use alternatives to the EJECT and SKIP directives.

First, EJECT and SKIP directives will be seen in the source, but not in the listing, and will interfere with the online examination of the code since they are in the same columns as the various paragraph-names and COBOL statements. Secondly, the more characters one has to key, the more chance for a keying error. Misspelling EJECT as "EJCET" or keying "SKIP1" as simply "SKIP" or "SKIP 1" will cause compiler errors and necessitate additional effort in program development.

RULE 1 - Use "/" in column 7 and blank or comment lines to control program formatting instead of "EJECT" and "SKIP" commands.

In addition to the above notions on comment and blank lines, there used to be some concern about the efficiency of the COBOL compiler itself. This notion was usually expressed somewhat like: "Since the compiler scans each line from left to right, if we put a '*' in column 7, it does not have to scan the rest of the line because it knows that the rest of the line is a comment. Therefore, a comment line with nothing else on the line is more efficient for the compiler than a completely blank line." This notion, in combination with the other problem of getting a keypuncher to key a blank card, convinced most people to use blank comment lines instead of blank lines (assuming that they were not using the SKIP directive mentioned above).

Now, not only are programmers generally doing their own program keying, but the efficiency of programmers is usually of more importance than that of the COBOL compiler. The cost to an organization of the additional time spent by the "expensive" programmer tabbing or otherwise spacing over to column 7 to type a "*" generally far outweighs the cost of the computer in scanning the remainder of the blank line to determine if it is in fact blank (assuming that the compiler wouldn't do that anyway for even the comment line so that it could copy it to the listing).

RULE 2 - When not as part of a comment block, use blank lines rather than blank comment lines.

Previous Chapter ----- Return to Index ----- Next Chapter