Source Code Control

ACUCOBOL-GT provides a method for conditionally modifying the source program at compile time. This is accomplished by having lines in the source that can be excluded or included at compile time. This can be used to maintain different versions of the program, perhaps to support different machine environments.

The -Si (include) flag controls the actions of the source code control system. It must be followed by an argument that specifies a pattern that the compiler will search for in the Identification Area of each source line. If the pattern is found, then the line will be included in the source program, even if it is a comment line. However, if the pattern is immediately preceded by an exclamation point, then the line will be excluded from the source (i.e., commented out). The exclamation point here stands for the notion not. Note that the pattern is case sensitive; enclose it in double quotes on systems such as VMS where you need to preserve its case.

The -Sx (exclude) flag works in the same fashion except that its meaning is reversed (i.e., lines with the pattern will be commented out and lines with a preceding exclamation point will be included).

Here is an example. Suppose that a source program is being maintained for both the UNIX and VMS environments. The following piece of code is in the program:

*  MOVE "/etc/helpfile" TO FILE-NAME.       UNX

This program fragment is ready to be compiled for the VMS system. If a UNIX version is desired, then the following command line will correct the source during compilation:

ccbl  -Si  UNX  -Sx  VMS  source

The first -Si flag will cause lines marked with UNX to be included in the source. The second flag will cause lines marked with VMS to be excluded from the source. An alternate way of doing the same thing would be:

*  MOVE "/etc/helpfile" TO FILE-NAME.        UNX

This would be compiled for UNIX systems with:

ccbl  -Si  UNX  source

The line marked with !UNX is commented out when this command is run because of the exclamation point. This alternate method is particularly appropriate if only two versions are being maintained.

This source code control system can be especially convenient if the source is being maintained for both ACUCOBOL-GT and non-ACUCOBOL-GT environments. The ACUCOBOL-GT extensions can be commented out and marked with a source-code control flag. When the program is compiled under ACUCOBOL-GT, these lines can be included.

Note: The patterns maintained in the Identification Area should be in upper case because some systems convert command lines into upper case. Also note that exclamation points usually need to be quoted on command lines. As a final note, the entire Identification Area is searched for the pattern; other information may be placed there too.