ContentsIndexPreviousNext

2.7.1 File Name Assignments

File names referenced in an ASSIGN clause can be dynamically reassigned at runtime by configuration variables (this is sometimes referred to as name aliasing). Each file's ASSIGN name is searched for in the configuration environment and, if found, replaced by the value of the matching configuration variable. The exact meaning of this reassignment is detailed in the section below on File Name Interpretation (2.8).

For example, if your code contains a SELECT statement like:

INPUT-OUTPUT SECTION.
FILE-CONTROL.
       SELECT idx-file
       ASSIGN TO DISK "idx.dat"
       BINARY SEQUENTIAL
       STATUS IS idx-status.

you could define a name alias for "idx.dat" in your runtime configuration file by adding the line:

idx.dat  /usr2/data/idx.dat

Whenever your application references "idx.dat" in a SELECT statement, the alias "/usr2/data/idx.dat" is substituted.

Remote name notation is allowed for file aliases if your runtime is client-enabled (for indexed files, remote name notation requires the Vision file system). See sections 5.2.1 and 5.2.2 for more information about client-enabled runtimes and remote name notation.


Note that aliasing is strongly recommended for accessing physical devices such as printers. This allows a program to easily adapt to the device naming conventions used at each individual site.
For portability across applications, the following names are recommended for device files:

PRINTER
System spooler, default printer
PRINTER1-9
System spooler, printers 1-9
FORM
Default special-form printer
FORM1-9
Special-form printers 1-9
TAPE
Default tape/floppy transport
TAPE1-9
Tape/floppy transports 1-9

For example, a COBOL program might assign a print file to the system spooler, printer number 2, with the following line:

ASSIGN TO PRINT "PRINTER2"

Although the assignment of these names to physical devices is arbitrary, the following conventions are recommended:

a) "PRINTER" devices should be assigned to the host operating system's spooler, if applicable. If the host operating system does not have a spooler, then they should be assigned directly to the print devices.

b) "FORM" devices should not be assigned to a spooler. They should, instead, be assigned directly to the printer. These are intended to be used by programs that need to control the printer directly without intervention by another program.

c) "TAPE" devices can be assigned in any sensible manner.

No names are initially assigned except on MS-DOS systems where the name "PRINTER" is initially assigned to the "PRN" device. You can change this by simply assigning a different value to "PRINTER". This process is covered in more detail in the section 2.8, "File Name Interpretation."