contents.gifindex.gifprev1.gifnext1.gif

2.8.2 File Name Examples

Following are some examples of the file name translation rules. These examples point out some of the more useful aspects of the translation rules.

Example 1: Default name handling

Suppose you wanted to place data files in the "\DATA" subdirectory on an MS-DOS system. You could then make the following assignment in the configuration file:

FILE_PREFIX      C:\DATA  D:\DATA

In this case, a file being created by an OPEN OUTPUT statement will be searched for first in the C:\DATA and D:\DATA directories. If it is found in either of these directories, that file will be removed and the new file placed in the same directory. If it is not found, however, then the new file will be created in the C:\DATA directory because that is the first one in the list.

Notice that the current directory is not mentioned in the above FILE-PREFIX configuration entry. This means that the current directory will not be searched for files. If you want the current directory to be one of the directories that is searched, add "." to the FILE-PREFIX configuration entry. If a particular file must be located in the current directory, use the "-F" flag. The "-F" can be specified in the ASSIGN name. For example, if you want to ensure that file "DIRLIST" is located in the current directory regardless of the value of FILE-PREFIX, place the following clause in your source code:

ASSIGN TO "-F DIRLIST"

The "-F" flag ensures that "DIRLIST" is not further translated or modified. Note that the "-F" flag also ensures that the name is not translated when it is used in a configuration variable. Thus, another way to accomplish the same result, is with these two steps:

1. Set the file name in the ASSIGN statement as:

ASSIGN TO "DIRLIST"

2. To cause the file to be placed in the current directory, place the following line in your configuration variable file, or set it in the DOS environment:

DIRLIST -F DIRLIST

Note that, in the above case, the file is placed in the current directory regardless of the contents of FILE-PREFIX.

Normally, you should avoid using the full directory path names or the "-F" flag in your source code. If you can, use FILE-PREFIX in the configuration file. This will provide the most flexibility in file management for each individual site.

Example 2: Accessing printers

ACUCOBOL-GT's name translation rules make it particularly easy to access a site's printers (and other devices) in a machine-independent fashion.

We recommend that you use some pre-designated names in your ASSIGN statements for files that are to be directed to a printer. Using these names will simplify the installation of runtime systems for sites using several ACUCOBOL-GT applications. The ASSIGN name for standard print files should be "PRINTER", or one of its variants "PRINTER1", "PRINTER2", etc. By convention, "PRINTER" is associated with the default printer on the host system, while the alternate names are associated with additional printers. For print files where you need direct control over the printer (to align special forms, for example), you should use one of the names: "FORM", "FORM1", "FORM2", etc. By convention, "FORM" devices are directly attached to the printer and "PRINTER" devices access printers through the system spooler (if available).

Each site can then place the appropriate definitions of these names in the configuration file (see "Runtime Configuration" above). The installation of "FORM" devices is easy--simply name the device using the "-D" flag. For example, to associate the name "FORM" with the "/dev/lp" device on a UNIX system, place the following line in the configuration file:

FORM -D /dev/lp

It is important to ensure that the users have access permissions to the named devices. For more information about print spooler issues, see Book 4, Appendix A, Section A.4.4 and the WIN$PRINTER library routine in Book 4, Appendix I.

The installation of "PRINTER" devices is only slightly more complicated. Because these should be spooled (if possible), you will usually need to use the "-P" flag to specify a program to receive the print output. The following notes give examples for various operating systems:

1. On UNIX systems, the name should be translated to the appropriate system spooler. This is usually either "lp" (for System V) or "lpr" (for Berkeley UNIX). You will usually need to specify additional flags to access devices other than the default one. If you are using the "lp" spooler, you should also specify the "-s" flag to prevent the "request id is . . ." message from appearing in the middle of your program.

For example, suppose the site has two printers, a high-speed line printer (the default) and a laser printer. Furthermore, suppose System V UNIX is being used and the laser printer is accessed with the flag "-dlaser".

The following two lines should then be placed in the configuration file:


PRINTER    -P  lp  -s

PRINTER1 -P lp -s -dlaser

2. On VMS systems the usual way to print files is with the PRINT system command. One recommended way of doing this is to enter the following line in the configuration file:

PRINTER -P %TMP% PRINT /NOIDENT /DELETE %TMP%

Be sure to use the options shown above (NOIDENT and DELETE), and feel free to add other options as desired.