PRINTER
From CometWiki
PRINTER
Syntax:
PRINTER device-name [,printer-control] [;printer-control] ...
PRINTER PROMPT [,printer-control] [;printer-control] ...
PRINTER file-name[.extension][,directory-name][,T|S|D|H]
where: T = text file S = standard data format (also called "SDF") D = comma-delimited fields H = comma-delimited fields, with header record containing field names
note: For output to delimited files (D or H), an extra parameter may be used to specify the delimiter character. The syntax for this parameter is:
DELIMITER is "delimiter-character"
PRINTER TERMINAL[,HTML|TEL|132]
HTML = display output in default web browser TEL = output on TeleVideo terminal or other 132-column workstation 132 = 132-column Comet workstation
Placement:
Place the PRINTER command before the REPORT command and after any ERASE, MARGIN, or LOG commands.
Discussion:
The PRINTER command sends your report output to a printer, a print spooler, a terminal or Comet screen, disk file, or web browser.
Printing to a printer or spooler
To print the report on a printer or to a spooler, specify the three-character name of the printer or spooler (e.g., PRINTER LP2).
Optionally, you can include one or more printer control codes in the PRINTER statement.
These control codes must be valid MTB printer mnemonics or hex control codes.
The control code(s) will be sent to the printer at the beginning of each page.
(This feature was added because of user comments that the default printer settings are restored on Novell networks if printing delays are encountered.)
In general, here is the syntax for using printer controls:
PRINTER LP1,(PrinterMnemonic1);(PrinterMnemonic2)
PRINTER LP2,"@xxxxxx@";(PrinterMnemonic1)
All of the characters following the comma (after the device name) are simply copied into a FORMAT statement and compiled into the report.
Printing to a user-specified device
The PRINTER PROMT command generates code in the report that prompts the user for a printer name when the report is run.
This command allows subsequent runs of the report to go to different printers without having to regenerate the report.
Optionally, you can include one or more printer control codes in the PRINTER PROMPT statement. See above for details.
Printing to a disk file
When you specify a disk file, type the name of the file where the report will be written (including an optional extension), and optionally, a three-character Comet directory name.
If you do not specify a directory, The Reporter uses the default directory.
You may also include a parameter to specify the file format.
If you do not include this parameter, the entire report (including page headers, column headings, and line breaks) is written to a sequential data file.
The following options are available for this parameter:
- T specifies a text file. The output will include all the headings, spaces, indentation, etc. allowed when output is to a terminal or printer.
- S specifies standard data format. This type of file contains fixed length fields, a fixed length record, and no field delimiters. This is commonly referred to as a "SDF" file.
- D specifies a delimited format. Fields are delimited with a comma, and string fields are enclosed in double quotes.
- H specifies a delimited file, and includes a header record with field names (see example below).
Notes:
The Reporter automatically includes a leading minus sign on negatively valued numeric fields when writing to a SDF or delimited output file.
As of Release 99.01, delimited and SDF formats can be printed to a printer. Printing to the terminal screen or web browser To direct the report to a terminal screen or web browser, use the PRINTER TERMINAL command.
Specify PRINTER TERMINAL, HTML to display the output in your default web browser.
The Reporter creates and launches an HTML file that contains the contents of the report. The following HTML commands are written to this file:
<HTML> <HEAD> <TITLE> -- report title -- </TITLE> </HEAD> <BODY>
Next, if one or more HEADER lines have been specified, they are written to the HTML file.
Then, a command is written to the file followed by the contents of the report.
After the last line of the report has been written, a command is written to the file.
If one or more FOOTER lines have been specified, they are then written to the HTML file.
Finally, The following HTML commands are written to the file:
</BODY> </HTML>
The Reporter then launches the HTML file and it is displayed in your web browser.
Specify PRINTER TERMINAL,TEL for 132-character screen output on TeleVideo terminals and compatible workstations.
Specify PRINTER TERMINAL,132 for 132-character screen ouput on Comet workstations.
History: The ability to add printer control codes/menmonics was added in Release 97.07.
The PRINTER PROMPT feature was added in Release 97.07.
Ouput to a text file was added in Release 98.03.
Output of delimited and SDF format to printers was added in Release 99.01.
Output to web browser (PRINTER TERMINAL,HTML) was added in Release 00.05.
Including printer controls in the PRINTER PROMPT command was added in Release 00.05.
The DELIMITER IS parameter was added in Release 01.01.
Example 1:
The following report will be printed on LP2: PRINTER LP2 INPUT CUSTOMER REPORT PRINT CUST.NAME,CUST.NUMBER
Example 2:
The following report will be printed on print spooler SP2 with a spool job message: PRINTER SP2,(Spool Message="Customer Name Listing") INPUT CUSTOMER REPORT PRINT CUST.NAME,CUST.NUMBER
Example 3:
The following report will be displayed on the user's screen: PRINTER TERMINAL INPUT CUSTOMER REPORT PRINT CUST.NAME,CUST.NUMBER
Example 4:
The following report will be displayed in HTML format in the user's web browser: PRINTER TERMINAL,HTML INPUT CUSTOMER REPORT PRINT CUST.NAME,CUST.NUMBER
Example 5:
The following report will prompt the user for a printer name when the report is run: PRINTER PROMPT INPUT CUSTOMER REPORT PRINT CUST.NAME,CUST.NUMBER
Example 6:
The following report will be written to a text file named MYREPORT.TXT on directory RPT: PRINTER MYREPORT.TXT,RPT,T INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Example 7:
The following report will be written to a standard data format file named MYREPORT.DAT on directory RPT: PRINTER MYREPORT.DAT,RPT,S INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Here is a sample of the disk file format: John Smith (800) 555-1212 5000.00 Jane Doe (800) 555-1313 6000.00
Example 8:
The following report will be written to a comma-delimited file named MYREPORT.CSV on directory RPT:: PRINTER MYREPORT.CSV,RPT,D INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Here is a sample of the disk file format: "John Smith","(800) 555-1212",5000.00 "Jane Doe","(800) 555-1313",6000.00
Example 9:
The following report will be written to a comma-delimited file, and will include a header record with field names: PRINTER MYREPORT.CSV,RPT,H INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Here is a sample of the disk file format. Note the header record. "NAME","PHONE NUMBER","CREDIT LIMIT" "John Smith","(800) 555-1212",5000.00 "Jane Doe","(800) 555-1313",6000.00
Example 10:
The following report will be written to delimited file with a user-specified delimiter character of "|". PRINTER MYREPORT,RPT,D,DELIMITER IS "| " INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Here is a sample of the disk file format. "John Smith"|"(800) 555-1212"|5000.00 "Jane Doe"|"(800) 555-1313"|6000.00
Example 11:
The following report will be written to delimited file with a user-specified delimiter character of "@09@" (the tab character). PRINTER MYREPORT.TAB,RPT,D,DELIMITER IS "@09@" INPUT CUSTOMER REPORT PRINT NAME,PHONE,CREDIT.LIMIT
Here is a sample of the disk file format. The fields are separated by a tab. "John Smith" "(800) 555-1212" 5000.00 "Jane Doe" "(800) 555-1313" 6000.00