Most modern programming languages give a way to add inline comments, generally those that use a newline character to indicate the end of a comment, and an arbitrary delimiter or sequence of tokens to indicate the beginning of a comment, while letting the beginning of the line being an interpreted instruction.
In COBOL, while commenting a whole line is well documented (it can be done by putting an asterisk symbol (*
) in column 7), finding documentation on whether or not you can comment the rest of the line beginning at an arbitrary position is harder.
The question is: can you comment the rest of a line beginning at an arbitrary position in COBOL?
Imagining that #
is the special character for this kind of comment, here is a fictive example of what is seeked:
*--- This structure is a dummy example
01 MY-STRUCTURE.
05 MY-VARIABLE PIC X VALUE '-'. # Valid values are in {-, a, b}
Enterprise COBOL V5.1 will support inline comments
From the Release Highlights
No, but you can write a program to "WRAP" your code when you submit it to the compiler. We did this 20 years ago.
for example.
THEN write a program that looks for the double dashes and have it delete the -- and the text. Then in your compile jcl, input your source code to the program, and the output to the compiler. Simple. Use the INSPECT statement.
And that is it. Removes the comments and sends to compiler.
COBOL documentation. Open, free.
And for a limited time, while it remains Draft and open for comment
That last link is almost guaranteed to expire when the COBOL 20xx Draft becomes a ratified ISO Standard, and is not really for redistribution, other than from the ISO PL22 WG4 source.
COBOL supports FIXED and FREE source code formats. FIXED is older, based on 80 column cards, with columns one to six for sequence numbers, 7 for directives and columns 8 thru 72 for program text.
Asterisk in column 7 is a FIXED form COBOL comment line.
There is a trick; place the asterisk in column 7 with the greater than symbol in column 8 and you have a comment line that works in both fixed and free format COBOL.
For compilers that will follow draft 20xx and
directives, there is another trick to assist in FIXED/FREE source compile support.
if the D is in column 7, with the two greater thans in 5 and 6, you have mixed FIXED and FREE source text support for debug lines as well.
Pre Cobol 2002 No
In Cobol 2002 *> was introduced. see Cobol 2002 and search in-line comment, which give this example:
There are other some exceptions