Using Environment Variables

To determine the system name of a file to match with a PL/I file, Open PL/I uses the name specified in the TITLE option of the OPEN statement. If the TITLE option is omitted, Open PL/I uses, by default, the name of the file constant or file variable in the PL/I program (shifted to uppercase). You can, instead, use system environment variables to easily specify the system names of files at run-time. The environment variable must be named in this fashion:

DD_name system-filename

where:

name is the TITLE-specified or default name indicated by the program.

Examples:

DECLARE DATA2 UPDATE FILE;   OPEN FILE(DATA2) /* no title */;
DECLARE FACTS STREAM FILE;   OPEN FILE(FACTS) TITLE('Report');

If you do not use environment variables to connect these openings with systems files, the following system names will be assumed for the files: DATA2 and Report.

Instead, prior to running the application, you could set environment variables as follows, causing the specified system files to be used. (Any directories used in the path names must exist.)

export DD_DATA2 /dir1/dir2/master.data
export DD_Report /doc/reports/deptA/week23.rep

In the second example, DD_Report was used rather than DD_FACTS, because of the TITLE option in that file's OPEN statement.