The ASSIGN clause associates the name of a file in a program with the actual external name of the data file.
All characters specified within the literal delimiters are used without any mapping.
If a literal or a word that is not a data-name is specified for the name, the assignment name is processed as follows:
For example:
my-comment-stl-myfile
In this example, my-comment is the comment, stl is the file-system-ID, and myfile is the system-file-name or environment-variable-name.
my-comment-am-myfile
In this example, my-comment-am is the comment, and myfile is the system-file-name or environment-variable-name.
Specifying alternate indexes: The compiler normally assigns default alternate index file names; however, you must override the default assignment when the file already exists and has alternate index files with names that differ from the default alternate index file names that are assigned by the compiler. For example, a file created through a different language, such as PL/I.
Alternate index names, if specified, must be specified in the same order as the alternate record keys are specified in the source program. You can omit alternate index names, but any other alternate index names must correspond to the position in the file definition. The following example shows how to specify the first and third alternate index names:
base-file-name(first-index-file-name,,third-index-file-name)
In the above example, the compiler will assign a default file name for the second alternate index file.
Alternate index file names are ignored for file systems that do not require separate alternate index files, such as the STL file system.
If the environment variable or data-name is specified for the assignment name, the data-name value or the environment variable value is processed as follows:
The environment variable value for a file is obtained when the program that contains the file is first run (or called) in its initial state. This value is kept for the file for subsequent calls to the program in the last-used state.
The value of the file ID specified with a data-name is obtained when the file is opened. On each subsequent OPEN for the file, the value is reobtained.
File declarations for an external file must have the same file-system identifier. If they do not, the error is caught during run time, and the application is terminated with an error message.
If there is no hyphen, or the character string to the left of the leftmost hyphen is less than three characters long, the entire character string is used as the system file name (possibly including drive and path names).
For information about specifying alternate indexes, see “Specifying alternate indexes” under Assignment name for non-environment variables and literals.