


ACUCOBOL-GT includes extended support for printing under Windows. In addition to the basic print spooler access procedures described below, the WIN$PRINTER runtime library routine provides easy access to extended Windows print spooler capabilities. See the entry for WIN$PRINTER in Appendix I of this book. Rules for printer handling are illustrated in User's Guide, section 2.8.2 .
Under Windows, you may print directly to the printer in exactly the same fashion as under MS-DOS. You must take care, however, to ensure that other programs are not printing at the same time. If they are, then you can get intermixed pages.
Under Windows, you may also print using the Windows spooler, even if your reports have embedded control codes. The spooler allows many programs to create print files at the same time, and also allows the user to do other tasks while the report is being printed.
Before you assign your print file to the Windows spooler, you must decide whether you want to control the format of each page directly (with embedded control codes) or whether you want the print spooler to format the pages.
Direct control
If you want to control the format yourself, then simply assign your print file to "-P SPOOLER-DIRECT".
For example, to assign "PRINTER1" to the spooler and retain direct control over formatting, enter the following line in your COBOL configuration file ("CBLCONFI"):
PRINTER1 -P SPOOLER-DIRECT
This causes the print job to be sent via the Windows spooler, but does not use the spooler to format the pages. You must use embedded control codes to handle formatting (much as you would under UNIX if you used the UNIX spooler).
You may use the WIN$PRINTER library routine to choose a printer. But because you completely control the printer, the various options provided by WIN$PRINTER are ignored. For example, WIN$PRINTER does not set the page size, page orientation, or font. Information returned from WIN$PRINTER, such as number of lines and columns on the page, may not be accurate and should not be used.
Because some print drivers do not flush the last page, be sure to end your last page with a form-feed (for example, WRITE . . . BEFORE ADVANCING PAGE). This ensures that all pages are printed. The ACUCOBOL-GT runtime ensures that no extra blank pages are printed at the end.
NOTE: If you were to code WRITE . . . AFTER ADVANCING PAGE instead of WRITE . . . BEFORE ADVANCING PAGE, you might receive a blank last page. This is because a blank line written on the new page causes the Windows subsystem to flush the page for some print drivers. ACUCOBOL-GT will ensure that entirely empty lines are not sent to the device (only the form-feed will be sent). But it is essential that (1) your COBOL code has trailing space removal specified for it (the default for print files) and (2) you have set the configuration option MIN-REC-SIZE to "0". Your other option would be to specify WRITE . . . BEFORE ADVANCING PAGE to avoid this potential problem.
If the user looks for the job in the spooler, it is named with the current title of the ACUCOBOL-GT window.
Spooler formatting
To use the Windows spooler and cause it to format the pages, 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 also 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 have assigned 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 above.