Source Format [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation
Micro Focus COBOL Language Reference
Source Format
Source code can be in free format (MF and XOPEN only) or fixed format
Fixed Format
In fixed format, the COBOL source format divides each COBOL source record
into 72 columns. These columns are used in the following way:
Columns 1 - 6 Sequence number
Column 7 Indicator area
Column 8 - 11 Area A
Columns 12 - Area B
72
For MF only: A COBOL source record can extend up to 80 columns in
length. The contents of columns 73 ot 80 are ignored by the COBOL
system.
Sequence Number
A sequence number of six digits can be used to identify each source
program line.
For MF only: If the first character position of the sequence number
field contains an asterisk, or any nonprinting control character (less
than the character SPACE in the ASCII collating sequence), then the line
is treated as comment and is not output to the listing file or device.
This facility allows an output listing file to be used as a source file
to a subsequent compilation.
For MF only: This support is sensitive to the MFCOMMENT compiler
directive. See your COBOL System Reference for details.
For ANS85 only: The sequence number can contain any character in the
computer's character set.
Indicator Area
An asterisk (*)in the indicator area marks the line as documentary
commentonly. Such a comment linecan appear anywhere in the program after
the IDENTIFICATION DIVISION header. Any characters from the ASCII
character set can be included in area A and area B of the line.
For MF, OSVS, and VSC2 only: A comment line can appear before the
IDENTIFICATION DIVISION header.
A slash (/) in the indicator area acts as a commentline above but causes
the page to eject before printing the comment.
A "D" or "d" in the indicator area represents a debugging line. Areas A
and B can contain any valid COBOL sentence.
A "-" in the indicator area represents a continuation of the previous
linewithout spaces or the continuation of a nonnumeric literal (see the
chapter Concepts of a COBOL Program).
For MF only: A "$" in the indicator area indicates a special line for
setting directives or conditional compilation.
Areas A and B
Section names and paragraph names begin in area Aand are followed by a
period and a space. Level indicators FD, SD, CD and RD begin in area A
and are followed in area B
or area A (ANS85 only) by the appropriate description. Level number 01
and 77 begin in area A and are follwed in area B or area A (ANS85 only)
by the data description. Level numbers 02 through 49, 66 and 88 begin in
area B.
For MF only: Level number 78 can begin in area A or area B.
For MF only: No rules regarding area A and area B are enforced except in
relation to comment-entries in the Identification Division.
For MF and XOPEN only: the concept of area A and area B is
removed when free form source code is used. See the next section
in this chapter for additional information on free format source
code.
More than one sentence is permitted in each source record.
Figure 1-1 shows the source formatof
a typical program.
000010 identification division.
000020 program-id. Stock-file-set-up.
000030 author. micro focus ltd.
000040 environment division.
000050 configuration section.
000060 source-computer. Mds-800.
000070 object-computer. mds-800.
000075 special-names. console is crt.
000080 input-output section.
000090 file-control.
000100 select stock-file assign "stock.it"
000110 organization indexed
000120 access dynamic
000130 record key stock-code.
000140 data division.
000150 file section.
000160 fd stock-file; record 32.
000170 01 stock-item.
000180 02 stock-code pic x(4).
000190 02 product-desc pic x(24).
000200 02 unit-size pic 9(4).
000210 working-storage section.
000220 01 screen-headings.
000230 02 ask-code pic x(21) value "stock code < >".
000240 02 filler pic x(59).
000250 02 ask-desc pic x(16) value "description <".
000260 02 si-desc pic x(25) value " >".
000270 02 filler pic x(39).
000280 02 ask-size pic x(21) value "unit size < >".
000290 01 enter-it redefines screen-headings.
000300 02 filler pic x(16).
000310 02 crt-stock-code pic x(4).
000320 02 filler pic x(76).
000330 02 crt-prod-desc pic x(24).
000340 02 filler pic x(56).
000350 02 crt-unit-size pic 9(4).
000360 02 filler pic x.
000370 procedure division.
000380 sr1.
000390 display space.
000400 open i-o stock-file.
000410 display screen-headings.
000420 normal-input.
000430 move space to enter-it.
000440 display enter-it.
000450 correct-error.
000460 accept enter-it.
000470 if crt-stock-code = space go to end-it.
000480 if crt-unit-size not numeric go to correct-error.
000490 move crt-prod-desc to product-desc.
000500 move crt-unit-size to unit-size.
000510 move crt-stock-code to stock-code.
000520 write stock-item; invalid go to correct-error.
000530 go to normal-input. 00054 end-it
000550 close stock-file.
000560 display space.
000570 display "end of program".
000580 stop run.
Figure 1-1. Sample Program Listing Showing Source Format (continued overleaf)
Program Listing Format
---------------------------------------------------------------------------------------------
| | |
| Column | Description |
| | |
---------------------------------------------------------------------------------------------
| | |
| Columns 1-6 | Sequence Number |
| | |
---------------------------------------------------------------------------------------------
| | |
| Column 7 | Indicator Area |
| | |
---------------------------------------------------------------------------------------------
| | |
| Columns 8-11 | Area A |
| | |
---------------------------------------------------------------------------------------------
| | |
| Columns 12-72 | Area B |
| | |
---------------------------------------------------------------------------------------------
For MF and XOPEN only: Free Format
Free format COBOL is selected using the SOURCEFORMAT"FREE" directive.
The first six characters are considered part of the normal source line
and may contain COBOL source code. Column 1 takes the role of the
indicator area as follows:
* comment line
/ comment line starting on a new page in the listing
file
D or d followed by space, debugging line
$ special line (for example, directive, conditional
compilation)
any other character normal source line
There are no continuation lines. Continuation of alphanumeric literals
is achieved through concatenation (for example, "A" & "B").
There is no distinction between area A and area B.
There is no fixed right margin, though for practical purposes this
implementation restricts the maximum length of a source line to 250
single-byte or 125 double-byte characters.
Comment-entries are only allowed on the same line as the paragraph header
and must not continue onto another line.
MPE/iX 5.0 Documentation