commentscobol

Is it possible to add inline comments in Cobol


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}

Solution

  • Pre Cobol 2002 No

    In Cobol 2002 *> was introduced. see Cobol 2002 and search in-line comment, which give this example:

    05 Field-X Pic XX *> Used in calculating the current THINGY
    ...
    MOVE ABC to XYZ  *> Current-XYZ
                 LMN *> Saved XYZ
    

    There are other some exceptions