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. The installation of FORM devices is easy--simply name the device using the -D flag. See Runtime Configuration for more information.

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 WIN$PRINTERWIN$PRINTER.

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.