This chapter provides an overview of printer-independent reports and discusses the sample program for selecting the printer type at runtime.
To create a printer-independent report, you must write a program that avoids using any characteristics that are unique to a specific printer. Although complete printer independence may be too restrictive, make your report as printer-independent as you can by following these guidelines:
The report should be readable if printed on a line printer. Graphics or solid lines printed with the graphic command are not printed on a line printer. Test your graphical report on a line printer.
Use only a small set of fonts. Font numbers 3, 4, and 5 and their boldface versions are the same regardless of the type of printer that you use (except for a line printer). Font 3 is Courier, font 4 is Helvetica, and font 5 is Times Roman. Note that on some HP printers, Helvetica may not be available. This reduces the common fonts to fonts 3 and 5 only.
Be aware of certain limitations. EPS-file images can be printed only on PostScript printers. HPGL-file images can be printed only on HP LaserJet Series 3 or higher or printers that emulate HP PCL at that level. BMP-file images can be printed using Microsoft Windows only. GIF-file and JPEG-file images are suitable only for HTML output. PRINT-IMAGE and PRINT-CHART may not work with old printers that use PostScript Level 1 or HP LaserJet Series II.
If your report is printer-neutral and does not specify a printer, you can specify the printer at runtime in two ways.
The first method is to use the -PRINTER:xx command-line flag, which specifies the output type for your report. Use the following commands:
If you are using the system shell, enter this command on the command line:
sqr test username/password -printer:ps
Note. Currently, PRINTER:WP sends output to the default Microsoft Windows printer. To specify a nondefault Windows printer, enter the following command: -PRINTER:WP:{Printer Name}. The {Printer Name} is the name assigned to your printer. For example, to send output to a Windows printer named NewPrinter, you would use -PRINTER:WP:NewPrinter. If your printer name has spaces, enclose the entire command in double quotes.
The second method of specifying the printer type is by using the USE-PRINTER-TYPE command.
See USE-PRINTER-TYPE.
In the following example, the PROGRAM section prompts the user to select the printer type at runtime. The relevant lines are shown like this:
begin-program input $p 'Printer type' ! Prompt user for printer type let $p = lower($p) ! Convert type to lowercase evaluate $p ! Case statement when = 'hp' when = 'hplaserjet' ! HP LaserJet use-printer-type hp break when = 'lp' when = 'lineprinter' ! Line Printer use-printer-type lp break when = 'ps' when = 'postscript' ! PostScript use-printer-type ps break when-other display 'Invalid printer type.' stop end-evaluate do list_customers end-program
In this code, the INPUT command prompts the user to enter the printer type. Because the USE-PRINTER-TYPE command does not accept a variable as an argument, the EVALUATE command is used to test for the six possible values and set the printer type accordingly.
The EVALUATE command is similar to a switch statement in the C language. It compares a variable to multiple constants and carries out the appropriate code.