PURPOSE: The PRINT statement is used to print data to a report in the form specified. Any field name, arithmetic expression, constant, or literal can be a print item. Also, SKIP, EJECT, TAB, and CENTER statements, without option clauses, can be used as print items.
PRINT [ON n] [\\items [@format]\\ [NOSKIP; NOCR] [HUSH] [IF; UNLESS clause]
[iterate clause]
n |
is a number or declared field that gives the number of the report to which the statement applies. |
items |
can be any of the following: Global,
system, or DS field name If a literal is included, it must be enclosed in matching single or double quotation marks. If no items are given, ACCENT R produces a carriage return-line feed. |
format |
can be a picture format enclosed in quotes, or Y, which is the number of a picture format declared with a PICTURE statement in the DECLARE section. The format must be preceded by the at sign (@). |
NOSKIP (or) NOCR |
suppresses the automatic carriage return-line feed. If NOCR or NOSKIP is not included, the PRINT statement produces an automatic carriage return-line feed after writing the item(s). |
The following system fields effect reports and are defined in the chapter on System Fields.
@BOTTOM_MARGIN, @TOP_MARGIN, @FOOTING_SIZE, @LINES, @TOF, @TOF_NUMBER, @PPOS, @PAGE, @PAGE_DIVIDER, @LINE, @TAB, @FF, @VT, @BS, @LF, @CR, and all the system fields starting with @LP.
PRINT "PUBLISHER LISTING"
PRINT @ETIME,2B,@CDATE
PRINT "TITLE_CODE",7B,"PRICE"
PRINT ON 1 2B,STORE_CODE:D,2B,QTY@1
PRINT ON 3 TAB 9,TITLE_CODE:M,TAB 17,PUB_CODE:AUX7,TAB40,NOCR
NOTES: The PRINT and TYPE statements serve two different purposes. TYPE displays information at the terminal. It is often used to prompt for user input. PRINT prints information in one or more reports. If one of the reports is going to the terminal, then the information in the relevant PRINT statements will be displayed at the terminal, but only as part of the report. A PRINT statement cannot appear in a PM unless a report is being created. If a report is displayed on a hard-copy terminal, use the PRINT statement. The TYPE does not invoke heading or footing or effect @PAGE or @LINE.
Applications that use input from the keyboard should use the TYPE statements to prompt the user, not PRINT.
PRINT can use the strings stored in the @LP system field series to facilitate the use of local printers. These system fields have been implemented with default ESCape sequences that are common to many VT-100 emulation terminals. The printer ESCape codes are specific to the C.Itoh Prowriter and AT&T 470 printer families.
The efficiency of the PRINT statement has been improved by buffering the output. Upon receipt of the end of line character, the I/O routines flush the buffer to the appropriate output device.
There are three ways to advance to the top of a new page:
PRINT... @TOF SKIP TO TOP EJECT
PRINT @TOF and EJECT are used for line printers and terminals that have top of form control. SKIP TO TOP uses line feeds to go to the next page and will work on any terminal.
For terminals that can perform a top-of-form function, PRINT... @TOF is the most common way to force a new page. When @TOF is encountered, it immediately prints the @TOF character, executes the FOOTINGS section, the bottom margin, page divider, top margin, and HEADINGS section. Note that @TOF advances to the top of the next page before FOOTINGS are executed. Therefore, PRINT @TOF should not be used when a FOOTINGS section is used. Likewise, the bottom margin and page divider should be left at their default values when PRINT @TOF is used. If FOOTINGS are required, SKIP TO TOP should be used to force the page. Note also that PRINT contains an implied carriage return, which executes at the end of the PRINT statement. This automatic carriage return will supply an extra line of space after the headings unless NOCR is included in the PRINT statement.
SKIP TO TOP may be used on terminals with or without top of form controls. It generates linefeeds to skip to the bottom of the print region, then executes the FOOTINGS section and bottom margin, prints the page divider, then executes the top margin and HEADINGS section.
EJECT is a special statement that causes the top of form character to be printed while bypassing the normal execution of HEADINGS, etc. EJECT is generally used in the INITIAL section to insure that a report always starts on a new page. EJECT does not increment the page number.