Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Identifying files to the operating system

The ASSIGN clause associates the name of a file within a program with the name of the file as it is known to the operating system.

You can use either an environment variable, a system file-name, a literal, or a data-name in the ASSIGN clause. If you specify an environment variable as the assignment-name, the environment variable is evaluated at run time and the value (with optional directory and path names) is used as the system file-name.

If you use a file system other than the default, you need to indicate the file system explicitly, for example, by specifying the file-system identifier before the system file-name. For example, if MYFILE is a Btrieve file, and you use F1 as the name of the file in your program, the ASSIGN clause would be:

SELECT F1 ASSIGN TO BTR-MYFILE

If MYFILE is not an environment variable, then the code above treats MYFILE as a system file-name. If MYFILE is an environment variable, then the value of the environment variable is used. For example, if the environment variable MYFILE is set as MYFILE=STL-YOURFILE, the system file-name becomes YOURFILE at run time, and the file is treated as an STL file, overriding the file-system ID used in the ASSIGN clause.

Note though that if you enclose an assignment-name in quotation marks or single quotation marks (for example, “BTR-MYFILE”), the value of the environment variable, if any, is ignored. The assignment-name is treated as a literal.

related tasks
Varying the input or output file at run time
Identifying files

related references
FILESYS
ASSIGN clause (COBOL for Windows Language Reference)


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)