Skip to main content

Problem:

System-wide default directives are contained in a cobol.dir file, either  in the source directory or in $COBDIR/etc/cobol.dir.  However, there are a few programs which cannot be compiled correctly without overriding one or more of the default directives.

Resolution:

In this example, the "RM" (Ryan-McFarland dialect) directive is set in cobol.dir, but must not be used for ore or two special programs, so NORM ("NO" "RM") must be set.

There are several ways to accomplish the override, all based upon the same concept:  If there are conflicting directives, e.g. RM and NORM, the last one the compiler "sees" is used.  From the documentation, manual "User's Guide", Chapter "COBOL System Interface (Cob)", section "Specifying Compiler Directives", the directive processing order is:

(any or all of the following do not necessarily exist for a given compiler run)

1. COBOL system default directives in cobol.dir

2. System default directives contained in $COBDIR/etc/cobopt

3. Content of environment variable COBOPT

4. Directives on the command line (each one preceded by the -C command switch)

5. $SET statements in the source code.

Within a given item, directives are processed left to right, top to bottom.

If NORM is to apply to only one or two programs, the easiest way is to insert a new line at the top of the source, starting with the "$" in column 7: $SET NORM (no period).

Alternatively, it could be put on the command line: cob -x special.cbl -C NORM

If multiple directives must be set differently for some programs, one could set up a separate directives file, e.g. special.dir.  Then, on the command line:

cob -x special.cbl -C USE\\"/where/it/is/special.dir\\"

Old KB# 2138