Progress
Programming
Handbook
Additional Options for Printing on Windows
On Windows, you can also get a list of printers, change the default printer for the session, and provide access to the Print dialog box.
Getting a List of Printers
You can use the GET-PRINTERS option of the SESSION statement to obtain a list of the printers configured for the current system. The following example shows you how to obtain the list of currently configured printers, select a printer, and print to it:
The following list explains the important elements in the example above:
- Create two variables: one for the output of SESSION:GET–PRINTERS; the other, for the output of LOOKUP.
- The SESSION: GET–PRINTERS method returns a comma-separated list of printers that are currently configured on the system.
- The LOOKUP function obtains an integer that gives the position of “SpecialPrinter” in the list. If the printer is not in the list, it returns a 0.
- The IF statement determines whether the printer “SpecialPrinter” is available and if so, prints to it.
- If the printer “SpecialPrinter” is not available, the ELSE DO statement prints to the default printer.
- The OUTPUT CLOSE statement stops sending output to the current destination and redirects output to the destination used prior to OUTPUT TO. See the section "Stream I/O vs. Screen I/O" for more information.
Changing the Default Printer
To change the default printer for the session, you can use the PRINTER–NAME option of the SESSION statement as shown in the following example.
- Create a variable for the output of SESSION:PRINTER–NAME.
- The SESSION:PRINTER–NAME attribute returns the name of the default printer.
- The SESSION:PRINTER–NAME attribute sets another printer, \\AB1\hplaser, as the default printer.
- The OUTPUT TO PRINTER prints the report on the printer \\AB1\hplaser.
- The SESSION:PRINTER–NAME attribute restores the original default printer.
Providing Access to the Print Dialog Box
You can use the SYSTEM–DIALOG PRINTER–SETUP statement to provide access to the Windows print dialog box. This allows the application user to set up the printer or even change the printer that receives the output.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |