The PRINT attribute applies to files with the STREAM and OUTPUT attributes. It indicates that the file is intended to be printed; that is, the data associated with the file is to appear on printed pages, although it can first be written on some other medium.
|
When PRINT is specified, the first data byte of each record of a PRINT file is reserved for an American National Standard (ANS) printer control character. The control characters are inserted by PL/I.
Data values transmitted by list- and data-directed data transmission are automatically aligned on the left margin and on implementation-defined preset tab positions.
The layout of a PRINT file can be controlled by the use of the options and format items listed in Table 34.
| Statement | Statement Option | Edit directed format item | Effect |
|---|---|---|---|
| OPEN | LINESIZE(n) | - | Established line width |
| OPEN | PAGESIZE(n) | - | Establishes page length |
| PUT | PAGE | PAGE | Skip to new page |
| PUT | LINE(n) | LINE(n) | Skip to specified line |
| PUT | SKIP[(n)] | SKIP[(n)] | Skip specified number of lines |
| PUT | - | COLUMN(n) | Skip to specified character position in line |
| PUT | - | X(n) | Places blank characters in line to establish position. |
LINESIZE and PAGESIZE establish the dimensions of the printed area of the page, excluding footings. The LINESIZE option specifies the maximum number of characters included in each printed line. If it is not specified for a PRINT file, a default value of 120 characters is used. There is no default for a non-PRINT file. The PAGESIZE option specifies the maximum number of lines in each printed page; if it is not specified, a default value of 60 lines is used. For example:
open file(Report) output stream print PAGESIZE(55) LINESIZE(110);
on endpage(Report) begin;
put file(Report) skip list (Footing);
Pageno = Pageno + 1;
put file(Report) page list ('Page '||Pageno);
put file(Report) skip (3);
end;
The OPEN statement opens the file Report as a PRINT file. The specification PAGESIZE(55) indicates that each page contains a maximum of 55 lines. An attempt to write on a page after 55 lines have already been written (or skipped) raises the ENDPAGE condition. The implicit action for the ENDPAGE condition is to skip to a new page, but you can establish your own action through use of the ON statement, as shown in the example.
LINESIZE(110) indicates that each line on the page can contain a maximum of 110 characters. An attempt to write a line greater than 110 characters places the excess characters on the next line.
When an attempt is made to write on line 56 (or to skip beyond line 55), the ENDPAGE condition is raised, and the begin-block shown here is executed. The ENDPAGE condition is raised only once per page. Consequently, printing can be continued beyond the specified PAGESIZE after the ENDPAGE condition has been raised. This can be useful, for example, if you want to write a footing at the bottom of each page.
The first PUT statement specifies that a line is skipped, and the value of Footing, presumably a character string, is printed on line 57 (when ENDPAGE is raised, the current line is always PAGESIZE+1). The page number, Pageno, is incremented, the file Report is set to the next page, and the character constant 'Page' is concatenated with the new page number and printed. The final PUT statement skips three lines, so that the next printing is on line 4. Control returns from the begin-block to the PUT statement that raised the ENDPAGE condition. However, any SKIP or LINE option specified in that statement has no further effect.