Include CL Source (INCLUDE)
Where allowed to run:
|
Parameters Examples Error messages |
The Include CL Source (INCLUDE) command includes external text into the source program being compiled. The external text must be valid CL commands that are valid in a compiled CL source. These commands can be declare statements (like DCL or DCLF), control flow statements (like IF or Select), or regular CL commands (like CRTLIB or RMVM). However, the included text cannot cause declare commands to appear after non-declare commands.
Restrictions:
- The INCLUDE command is valid only within a CL program or ILE CL procedure.
- You must have use (*USE) authority to the file specified for the Source file (SRCFILE) or Source stream file (SRCSTMF) parameter, and execute (*EXECUTE) authority to the library which contains the source file.
- The record length of the source file specified for the SRCFILE parameter must be the same or less than the record length of the source file which contains the root CL source program being compiled. Records copied from the INCLUDE source file that are longer than the root CL source file record length will be truncated on the right. This may cause compile-time errors or unexpected runtime behavior of the CL program or CL procedure.
- The Source member (SRCMBR) and Source file (SRCFILE) parameters cannot be specified with the Source stream file (SRCSTMF) parameter.
Top |
Parameters
Keyword | Description | Choices | Notes |
---|---|---|---|
SRCMBR | Source member | Name | Optional, Positional 1 |
SRCSTMF | Source stream file | Path name | Optional |
SRCFILE | Source file | Single values: *INCFILE Other values: Qualified object name |
Optional, Positional 2 |
Qualifier 1: Source file | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB |
Top |
Source member (SRCMBR)
Specifies the source member that contains the CL program source to be included.
- name
- Specify the name of the source member.
Top |
Source stream file (SRCSTMF)
Specifies the path name of the stream file containing the CL source to be included.
The path name can be either absolutely or relatively qualified. An absolute path name starts with '/'; a relative path name starts with a character other than '/'.
If absolutely-qualified, the path name is complete.
If relatively-qualified, the path name is completed by pre-appending the searched including directory to the path name. The including directories to be searched are specified by the INCDIR parameter. The including source file will be searched by the following order:
- The source directory.
- The directories specified in the INCDIR parameter.
Top |
Source file (SRCFILE)
Specifies the source file that contains the source member to be included.
Single Values
- *INCFILE
- The file specified for the INCLUDE file (INCFILE) parameter on the CL command used to invoke the CL compiler is used.
Qualifier 1: Source file
- name
- Specify the name of the source file.
Qualifier 2: Library
- *LIBL
- All libraries in the library list for the current thread are searched until the first match is found.
- *CURLIB
- The current library for the thread is used to locate the source file. If no library is specified as the current library for the thread, the QGPL library is used.
- name
- Specify the name of the library to be searched.
Top |
Examples
Example 1: Include CL Source Using Default INCLUDE File
INCLUDE SRCMBR(DCLSET1) SRCFILE(*INCFILE)
This command will cause the CL program source in member DCLSET1 to be included at compile time. Member DCLSET1 must be located in the file specified for the INCFILE parameter on the CL command which invoked the CL compiler.
Example 2: Include CL Source From Specified File
INCLUDE SRCMBR(SUBR1) SRCFILE(MYLIB/COMMONSUBR)
This command will cause the CL program source in member SUBR1 to be included at compile time. Member SUBR1 must be located in file COMMONSUBR in library MYLIB.
Example 3: Include CL Source From Specified Stream File
INCLUDE SRCSTMF('/dir/pay_data.cl')
This command will cause the CL program source in stream file '/dir/pay_data.cl' to be included at compile time.
Top |
Error messages
None
Top |