The Declare File (DCLF) command is used to declare a display or database file to your CL procedure or program. The DCLF command cannot be used to declare files such as tape, printer, and mixed files.
You can declare up to five files in a CL procedure or OPM program. The DCLF command has the following parameters:
DCLF FILE(library-name/file-name) RCDFMT(record-format-names) OPNID(open_id_name)
Note that the file must exist before the module or program is compiled.
If you are using a display file in your procedure or program, you may have to specify input and output fields in your DDS. These fields are handled as variables in the procedure or program. When processing a DCLF command, the CL compiler declares CL variables for each field and option indicator in each record format in the file. For a field, the CL variable name is the field name preceded by an ampersand (&). For an option indicator, the CL variable name is the indicator that is preceded by &IN.
You use the open file identifier (OPNID) parameter to uniquely identify an instance of a declared file so that multiple files can be declared. If you use the OPNID parameter, then for a field, the CL variable name is the field name preceded by an ampersand (&), the OPNID value, and an underscore (_). For an option indicator, the CL variable name is the indicator preceded by an ampersand (&), the OPNID value, an underscore, and "IN".
For example, if a field named INPUT and indicator 10 are defined in DDS, the DCLF command automatically declares them as &INPUT and &IN10. This declaration is performed when the CL module or program is compiled. Up to 50 record format names can be specified on one command, but none can be variables. Only one record format may be specified for a database file.
If the following DDS were used to create display file CNTRLDSP in library MCGANN:
|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8 A R MASTER A CA01(01 'F1 RESPONSE') A TEXT 300 2 4 A RESPONSE 15 1 8 4 BLINK A A
DCLF MCGANN/CNTRLDSP
The compiler will expand this statement to individually declare all display file variables. The expanded declaration in the compiler list looks like this:
• • • 00500- DCLF(MCGANN/CNTRLDSP) 04/02/03 QUALIFIED FILE NAME - MCGANN/CNTRLDSP RECORD FORMAT NAME - MASTER CL VARIABLE TYPE LENGTH PRECISION (IF *DEC) &IN01 *LGL 1 &TEXT *CHAR 300 &RESPONSE *CHAR 15 • • •
If the DCLF source statement includes an OPNID parameter:
DCLF MCGANN/CNTRLDSP OPNID(OPENID1)
The expanded declaration in the compiler list will look like this:
• • • 00500- DCLF FILE(MCGANN/CNTRLDSP) OPNID(OPENID1) 04/02/03 QUALIFIED FILE NAME - MCGANN/CNTRLDSP RECORD FORMAT NAME - MASTER CL VARIABLE TYPE LENGTH PRECISION TEXT &OPENID1_IN01 *LGL 1 &OPENID1_TEXT *CHAR 300 &OPENID1_RESPONSE *CHAR 15 • • •