This operation code allows you to select a specific printer and set properties.
CALL "WIN$PRINTER" USING WINPRINT-SET-PRINTER, WINPRINT-SELECTION GIVING RESULT
|WINPRINT-SELECTION||Group item defined in
winprint.def as follows:
01 WINPRINT-SELECTION. 03 WINPRINT-NAME PIC X(80). 03 WINPRINT-PORT PIC X(80). 03 WINPRINT-DRIVER PIC X(80). 03 WINPRINT-DRV-VERSION SIGNED-INT. 03 WINPRINT-NO-OF-PRINTERS SIGNED-SHORT. 88 WPRTERR-NO-PRINTERS VALUE -1. 03 WINPRINT-IS-DEFAULT SIGNED-SHORT. 88 WPRT-IS-NOT-DEFAULT VALUE 0. 88 WPRT-IS-DEFAULT VALUE 1. 03 WINPRINT-COPIES SIGNED-SHORT. 88 WPRT-HAS-NO-COPY VALUE 1. 03 WINPRINT-ORIENTATION SIGNED-SHORT. 88 WPRT-HAS-NO-LANDSCAPE VALUE 0. 88 WPRT-HAS-LANDSCAPE VALUE 1. 03 WINPRINT-QUALITY SIGNED-SHORT. 03 WINPRINT-CURR-ORIENTATION SIGNED-SHORT. 03 WINPRINT-CURR-COPIES SIGNED-SHORT.
WINPRINT-NAME must hold the name of the printer as received by WINPRINT-GET-PRINTER-INFO. If WINPRINT-COPIES is set to a positive value greater than one, you may use WINPRINT-CURR-COPIES to set the number of copies to print. If WINPRINT-CURR-COPIES is set to zero, the printer driver default is used. If WINPRINT-ORIENTATION is set to a positive value, then WINPRINT-CURR-ORIENTATION may be set to any of the following values:
|WPRTSEL-ORIENT-DEFAULT||For printer default.|
|WPRTSEL-ORIENT-PORTRAIT||For portrait orientation.|
|WPRTSEL-ORIENT-LANDSCAPE||For landscape orientation.|
WINPRINT-QUALITY may be used to select varying grades of print quality. One may use the predefined constants for this purpose:
|WPRTSEL-QUALITY-DEFAULT||For printer default.|
|WPRTSEL-QUALITY-HIGH||For high quality.|
|WPRTSEL-QUALITY-MEDIUM||For medium quality.|
|WPRTSEL-QUALITY-LOW||For low quality.|
|WPRTSEL-QUALITY-DRAFT||For draft quality.|
The steps for actually specifying a printer differ depending on whether or not you know the name of the printer.
If you know the name of the printer, set WINPRINT-NO-OF-PRINTERS to 0, and set WINPRINT-NAME to the name of the printer as given in the Printers folder under Settings. Specify any settings you desire and call WIN$PRINTER using WINPRINT-SET-PRINTER.
If you don't know the name of the printer, start by calling WIN$PRINTER using WINPRINT-GET-NO-PRINTERS and storing the result in an appropriate variable. Next, enumerate the printers by iterating through the available printers starting with 1, ending with the value obtained from WINPRINT-NO-OF-PRINTERS. Stop when you have found the printer you want. Specify the settings you desire and call WIN$PRINTER again, this time using WINPRINT-SET-PRINTER. An example of this scenario can be found in the sample program prndemo.cbl.
The WINPRINT-SET-PRINTER operation also allows you to change some printer settings while the printer is open, or spooling. For example, if you are printing a portrait-oriented report that contains a single-page table in landscape format, you would need to change the page orientation during printing. When you are using this feature, the only properties you can alter for this op-code are those controlling the number of copies, the page orientation and the print quality. All other properties for this op-code use the existing settings.
If you call WINPRINT-SET-PRINTER on an open print job, there is an implicit form feed. WINPRINT-SET-PRINTER must be called before you begin to print the page with the different setting, and after all printing is done on the page immediately preceding the page with the different setting. When the current page is finished, the print cursor is positioned at the top leftmost point on the new page. The new page accepts the current values specified for number of copies, page orientation and print quality, provided they are within legal parameters for the particular setting.
Because this feature of WINPRINT-SET PRINTER occurs during a print job, it alters the document being printed, particularly by setting any current page margins to the printer default values. This means that if you have customized margins and you call WINPRINT-SET-PRINTER on an open printer, you will have to reset the margins after the call to reestablish your custom margin settings.
Margin limitations may vary from portrait to landscape on the same printer and you may not be able to specify the same values for both orientations.
Changing the output device with this operation will reset any columns you have set using WINPRINT-COLUMN op-codes.
Here is an example of how to specify a printer named Gutenberg:
INITIALIZE WINPRINT-NO-OF-PRINTERS. MOVE "Gutenberg" TO WINPRINT-NAME. CALL "WIN$PRINTER" USING WINPRINT-GET-PRINTER-INFO WINPRINT-SELECTION. *we want to set landscape orientation MOVE WPRTSEL-ORIENT-LANDSCAPE TO WINPRINT-CURR-ORIENTATION. *with this call, subsequent print jobs will print in landscape *orientation from Gutenberg CALL "WIN$PRINTER" USING WINPRINT-SET-PRINTER WINPRINT-SELECTION.