Include Files – VMS
The Embedded SQL include statement provides a means to include external files in your program's source code. Its syntax is:
exec sql include filename
filename
A single quoted string constant specifying a file name, or a logical name that points to the file name. If you do not specify an extension to the filename, the default Fortran input file extension ".sf" is assumed.
This statement is normally used to include variable declarations, although it is not restricted to such use. For more details on the include statement, see the SQL Reference Guide.
The included file is preprocessed and an output file with the same name but with the default output extension ".for" is generated. You can override this default output extension with the -o.ext flag on the command line. In the original source file that specified the include statement, a new reference is made to the output file with the Fortran include statement. If you use the -o flag with no extension, an output file is not generated for the include statement. This is useful for program libraries that use MMS dependencies.
If you use both the -o.ext and the -o flags, then the preprocessor generates the specified extension for the translated include statements in the program, but does not generate new output files for the statements.
For example, assume that no overriding output extension was explicitly given on the command line. The Embedded SQL statement:
exec sql include 'employee.dcl'
is preprocessed to the Fortran statement:
include 'employee.for'
and the employee.dcl file is translated into the Fortran file "employee.for".
As another example, assume that a source file called "inputfile" contains the following include statement:
exec sql include 'mydecls'
The name "mydecls" can be defined as a system logical name pointing to the file "dra1:[headers]myvars.sf" by means of the following command at the system level:
define mydecls dra1:[headers]myvars
Because the extension ".sf" is the default input extension for Embedded SQL include files, it does not need to be specified when defining a logical name for the file.
Assume now that "inputfile" is preprocessed with the command:
esqlf -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 Fortran statement:
include 'dra1:[headers]myvars.hdr'
and the Fortran file "dra1:[headers]myvars.hdr" is generated as output for the original include file, "dra1:[headers]myvars.sf".
You can also specify include files with a relative path. For example, if you preprocess the file "dra1:[mysource]myfile.sf", the Embedded SQL statement:
exec sql include '[-.headers]myvars.sf'
is preprocessed to the Fortran statement:
include '[-.headers]myvars.for'
and the Fortran file "dra1:[headers]myvars.for" is generated as output for the original include file, "dra1:[headers]myvars.sf".