COBOLworx employee?Sign in

← Knowledge Base

COBOL

COBOL Fixed (Original) Format

Think Punched Cards!

This topic is helpful for reading COBOL in the original 1960s through the 1980s formats. The COBOL standard dropped the capitalization requirements and introduced “Free Form” for source code in the 1990s. But billions of lines conform to Fixed Form so you should be familiar with it.

The original specification of COBOL was done at a time when the primary form of data entry to computers was the 80-column punched card. A 1950s and ’60s keypunch could only punch upper case letters, numbers, and special characters (and not all that many of those). So the source code format for the COBOL language was defined based on the 80-column card.

Since all data input to the computer was in decks of cards, sometimes thousands of cards, the cards “usually” had a sequence number. The COBOL committee decided that a six-digit sequence number at the beginning of each card was adequate. Those columns were ignored by the compiler. But if you sequenced the deck and dropped it, a card-sorter put it back in sequence quickly.

Column (position) seven was reserved for “indicators” like “*” marking the card as a comment or “D” marking it as a “debug line” (only used when the program was compiled in debug-mode). There are more details about these indicators below.

Columns eight to seventy-two were the text or program area. The last eight columns were also ignored by the compiler. Either the leading six or the trailing eight columns could be and were used for sequencing, notes, or left blank.

So, a card deck could look like:

      *  1         2         3         4         5         6         7         8
123456*8901234567890123456789012345678901234567890123456789012345678901234567890
123400* THIS IS A CARD DECK. THIS CARD HAS A SEQUENCE NUMBER
      * MORE COMMENTS, NO SEQUENCE 
       IDENTIFICATION DIVISION.                                         ABCDEFGH
123405 PROGRAM-ID. HELLO.                                               IJKLMNOP
123410 PROCEDURE DIVISION.
       END PROGRAM HELLO.

The formal specification further divides the text/program section into AREA A and AREA B but those definitions are no longer enforced by modern compilers.

Indicator Column Codes

Indicator Meaning
* The entire line is treated as a comment
/ The entire line is treated as a comment and a listing of the program should go to the next page (page eject)
- A hyphen signals that this is a continuation line
[space] A space signals that it is just a program line

Floating Indicators

Recent standards introduced floating indicators. These are necessary for Free Format and MAY be used in the text/program area of Fixed Format COBOL. Also, modern compilers have compiler controls to let programmers switch between Fixed and Free formats so new code can use the less restrictive Free Format. Neither of these topics are covered here.