ContentsIndexPreviousNext

1.2.5.1 Spooler formatting

There are two ways to use the Windows spooler to format your print file: "-P SPOOLER" and "-Q <printername>". (If you wish to control formatting yourself, refer to section 1.2.5.2 "Direct Control" below.)

-P SPOOLER

If you want to use the default printer and font, simply assign your print file to
"-P SPOOLER". For example, to assign "PRINTER1" to the spooler, enter the following line in your COBOL configuration file ("CBLCONFI"):

PRINTER1  -P  SPOOLER

By default, the runtime system assigns the "PRINTER" device to the spooler. You may change this in the configuration file by assigning "PRINTER" to some other name.

When the runtime opens a file assigned to "-P SPOOLER", it automatically initiates a job with the Windows spooler and constructs print pages in accordance with your program. The runtime uses the default printer and font. If the user looks for the job in the spooler, it is named with the current title of the ACUCOBOL-GT window.


Note: The Windows spooler operates by drawing your report on each page. It constructs its own control codes to handle formatting. If you assign your print file to "-P SPOOLER" but your file contains device-dependent control sequences (such as those used to shift to a condensed font, or to print a form and then fill it in), the codes will be passed to the spooler as data and thus will not be interpreted correctly. If you have reports that depend on embedded control codes, you should print those directly to the device, or assign the print file to "-P SPOOLER-DIRECT," as described below.

-Q <printername>

If you want the Windows spooler to format the pages of your report, but you want to use a particular printer, assign your print file to:

PRINTER1 -Q \\printername

in the configuration file ("CBLCONFI"). Printername may be up to 80 characters long and contain embedded spaces. The name may not include the semicolon character (;) or be surrounded by single or double quotes. The pages are printed in the manner described in "-P SPOOLER" above. The sample programs "graphprn.cbl" and "prndemox.cbl" contain examples of these functions.

To determine a valid printername, use the WIN$PRINTER library routine to obtain the name of the desired printer. (This is described in Appendix I under the WINPRINT-SET-PRINTER operation code in "Specifying a Printer.") Then add the following line to your code:

MOVE "-Q \\printername" TO WS-PRINTER-NAME.

When the runtime opens a file assigned to "-Q <printername>" it will set the Windows print spooler to use this printer. The printer driver must be installed on the computer from which you print. If printername is not recognized by the runtime, a dialog box allows you to choose a printer manually.


Note: If you want to access a printer using a UNC path, you will have to print directly to the printer by defining PRINTER as "-D PRN", just as you would under Extended-DOS. If you use the UNC path, Windows formatting is not supported.
Setting Options:

You may also use "-Q <printername>" to set several other printing options in the configuration file using the following syntax:

<-Q printername>[;option1=x][;option2=x][;option3=x]...

The following options may appear in any order. Options not supported by the printer driver are ignored. Printername should appear as shown in WINPRINT-NAME, but the options are case insensitive.


Note: The options PITCH, COLS, LINES, and FONT are all mutually dependent. Omitting one or more of these options may cause the resulting printout to look wrong.
DIRECT - Setting DIRECT to "ON" will cause the job to print as if the configuration file was set to "-P SPOOLER-DIRECT" (described in section 1.2.5.2 below). This will also disable any use of additional options. Setting DIRECT to the default of "OFF" causes the job to print to the selected printer as if the configuration file was set to "-P SPOOLER".

FONT - Use FONT to specify a single font name. The font name may have embedded spaces, but may not contain double or single quotes. If the font does not exist, the closest matching font will be chosen.


Note: The runtime does not align columns. If you are printing a report containing columns, you should use a fixed-width font.
PITCH - This value specifies the point size of the font. Pitch does not determine the number of characters per line. If you use a larger pitch, the characters simply appear more crowded. For example, when printing 132 columns, a pitch of 10 will produce better character spacing than a pitch of 12.

COLS - Specifies the number of columns (width) on the page. This number is not validated by the runtime or the spooler. Choose a number of columns that coordinate with the selected font and pitch when designing the report layout.

LINES - Specifies the lines (rows of characters) on the page. This number is not validated by the runtime or the spooler. Choose a number of lines that is compatible with the selected font and pitch when designing the report layout.

ORIENTATION - If your printer supports this feature, ORIENTATION allows you to specify LANDSCAPE or PORTRAIT orientation for the report.


Note: The default value of ORIENTATION is driver specific.
COPY - If your printer supports this feature, COPY allows you to specify the number of copies to print.

Examples

To use the Windows spooler with an HP Laserjet printer driver located on SERVER1, and specify the font, font size, width and number of lines in the report, enter the following into CBLCONFI:

PRINTER1 -Q \\SERVER1\HP Laserjet IV;FONT=Times New Roman;PITCH=12;COLS=132;LINES=65.

To print three copies directly to the printer on a server named GUTENBERG in Landscape orientation, enter the following into CBLCONFI:

PRINTER1 -Q \\GUTENBERG\HP Laserjet IV;DIRECT=ON;ORIENTATION=LANDSCAPE;COPY=3