Include File Processing
The EQUEL include statement provides a means to include external files in your program's source code. Its syntax is:
## include filename
Filename is a double quoted string constant specifying a file name or an environment variable that points to the file name. You must use the default extension ".qcb" on names of include files unless you override this requirement by specifying a different extension with the -n flag of the eqcbl command.
This statement is normally used to include variable declarations although it is not restricted to such use. For details about the include statement, see the QUEL Reference Guide.
The included file is preprocessed and an output file with the same name but with the default output extension ".cbl" for Linux is generated. You can override this default output extension with the -o.ext flag on the command line. The reference in the original source file to the included file is translated in the output file to the specified include output file. If you use the -o flag, with no extension, no output file is generated for the include file.
Linux: For example, assume that no overriding output extension was explicitly given on the command line. The EQUEL statement:
## INCLUDE "employee.qcb"
is preprocessed to the COBOL statement:
COPY "employee.cbl"
and the file "employee.qcb" is translated into the COBOL file "employee.cbl.".
As another example, assume that a source file called "inputfile" contains the following include statement:
## INCLUDE "mydecls"
The name "mydecls" is defined as a system environment variable pointing to the file "/src/headers/myvars.qcb" by means of the following command at the shell level:
$ setenv mydecls /src/headers/myvars.qcb
Assume now that "inputfile" is preprocessed with the command:
$ eqcbl -o.hdr inputfile
The command line specifies ".hdr" as the output file extension for include files. As the file is preprocessed, the include statement shown earlier is translated into the COBOL statement:
COPY "/src/headers/myvars.hdr"
and the COBOL file "/src/header/myvars.hdr" is generated as output for the original include file, "/src/header/myvars.qbc."
You can also specify include files with a relative path. For example, if you preprocess the file "/src/mysource/myfile.qcb," the EQUEL statement:
## INCLUDE "../headers/myvars.qcb"
is preprocessed to the COBOL statement:
COPY "../header/myvars.cbl"
and the COBOL file "/src/headers/myvars.cbl" is generated as output for the original include file, "/src/headers/myvars.qcb."
Last modified date: 11/09/2022