HP OpenVMS Systems Documentation
By default, the compiler expects terminal-format source lines. The compiler expects ANSI format only when the command line includes the ansi compiler option.
The reference format rules for spacing take precedence over all other
1.3.1 ANSI Format
The ANSI source reference format describes COBOL programs in terms of character positions on an input line. A source program line has 80 character positions as shown in Figure 1-1.
Figure 1-1 Source Program Line
Immediately to the left of the leftmost character position.
Between character positions 6 and 7.
Between character positions 7 and 8.
Between character positions 11 and 12.
Between character positions 72 and 73.
The six character positions between Margin L and Margin C. The contents can be any characters from the computer character set.
The compiler does not check the uniqueness of the contents. However, the compiler does check for the ascending sequence of the contents if the compiler command line includes the sequence compiler option.
The seventh character position. The character in this position directs the compiler to interpret the source line in one of the following ways:
|Character||Source Line Interpretation|
|space ( )||Default. The compiler processes the line as normal COBOL text.|
|hyphen (-)||Continuation line. The compiler processes the line as a continuation of the previous source line.|
|asterisk (*)||Comment line. The compiler ignores the contents of the line. However, the source line appears on the program listing.|
|slash (/)||New listing page. The compiler treats the line as a comment line. However, it advances the program listing to the top of the next page before printing the line.|
|A-Z, a-z||Conditional compilation lines. The compiler processes the line as normal COBOL text if you specify the DEBUGGING MODE clause in the SOURCE-COMPUTER paragraph, or if you specify the conditionals compiler option in the command line. If you do not specify either, the compiler processes this line as a comment line.|
The four character positions between Margin A and Margin B. Area A contains division headers, section headers, paragraph headers, paragraph-names, level indicators, and certain level-numbers.
The 61 character positions between Margin B and Margin R. Area B contains all other COBOL text.
The eight character positions immediately following Margin R. The compiler ignores the contents of the identification area. However, the contents appear on the source program listing.
A hyphen in a line's indicator area causes its first nonblank character in Area B to be the immediate successor of the last nonblank character of the preceding line. This continuation excludes intervening comment lines and blank lines.
However, if the continued line ends with a nonnumeric literal without a closing quotation mark, the first nonblank character in Area B of the continuation line must be a quotation mark. The continuation starts with the character immediately after the quotation mark. All spaces at the end of the continued line are part of the literal. Area A of the continuation line must be blank.
If the indicator area is blank:
001010 01 NUMERIC-CONTINUATION. 001020 03 NUMERIC-LITERAL PIC 9(16) VALUE IS 123 001030- 4567890123456. 001040 01 NONNUMERIC-CONTINUATION. 001050 03 NONNUMERIC-LITERAL PIC X(40) VALUE IS "AB 001060- "CDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn". 001070 PROCEDURE DIVISION. 001080 SENTENCE-CONTINUATION. 001090 IF NUMERIC-LITERAL NOT = SPACES 001100 DISPLAY "NUMERIC-LITERAL NOT = SPACES" 001110 ELSE 001120 DISPLAY NUMERIC-LITERAL.
Lines 001020 and 001030 show continuation of a numeric literal. Lines 001050 and 001060 continue a nonnumeric literal. A sentence that spans four lines begins on line 001090.
A comment line is any source line with an asterisk (*) or slash (/) in its indicator area. Area A and Area B can contain any characters from the computer character set. Comment lines can be anywhere in a source program or library text.
A conditional compilation line is any source line after the OBJECT COMPUTER paragraph that includes one of these uppercase or lowercase alphabetic characters in its indicator area: A to Z, a to z. The compiler processes the line as normal COBOL text if you specify the DEBUGGING MODE clause in the SOURCE COMPUTER paragraph.
The compiler processes the line as normal COBOL text if you include the appropriate conditionals compiler option in the command line.
If you specify neither, the compiler processes this line as a comment line.
Lines conditioned by one letter can be compiled or treated as comments independently of other conditional compilation lines. On OpenVMS systems, for instance, if you compile with /CONDITIONALS=(A,B), lines conditioned with A and B compile while those conditioned by other letters are treated as comments.
See Chapter 8 for additional information on the interaction between conditional compilation lines and the COPY statement.
Pseudo-text character-strings and separators can start in either Area A or Area B. However, if there is a hyphen in the indicator area of a line that follows the opening pseudo-text delimiter, Area A of the line must be blank.
The normal rules for line continuation apply to the formation of text-words.
Pseudo-text is described in Chapter 8.
The compiler recognizes the end of the input line as Margin R. Tab characters, other than those in nonnumeric literals, cause the compiler to generate enough space characters to position the next character at the next tab stop. The compiler's tab stops are at character positions 8, 12, 20, 28, 36, 44, 52, 60, 68, and 76.
The following example shows how the compiler interprets carriage return and horizontal tab characters in a source program:
000100*The following record description shows the source line format[Return] 000110 01[Tab]RECORD-A.[Return] 000120[Tab][Tab]03 GROUP-A.[Return] 000130[Tab][Tab][Tab]05 ITEM-A[Tab]PIC X(10).[Return] 000140*[Tab]The tab character in the nonnumeric literal[Return] 000150*[Tab]on the next line is stored as one character[Return] 000160[Tab][Tab][Tab]05 ITEM-B[Tab]PIC X VALUE IS "[Tab]".[Return] 000170[Tab][Tab]03 ITEM-C[Tab][Tab]PIC X(10).[Return] 000180D01[Tab]RECB REDEFINES RECORD-A[Tab]PIC X(21).[Return]
000100*The following record description shows the source line format 000110 01 RECORD-A. 000120 03 GROUP-A. 000130 05 ITEM-A PIC X(10). 000140* The tab character in the nonnumeric literal 000150* on the next line is stored as one character 000160 05 ITEM-B PIC X VALUE IS "[Tab]". 000170 03 ITEM-C PIC X(10). 000180D01 RECB REDEFINES RECORD-A PIC X(21).