HEADING [ON channel] header
|channel||Optional — An integer that specifies a logical print channel. The default is 0.|
|header||The header to print on output pages, specified as a string enclosed in double quotation marks. This header can consist of any combination of literal text and code characters. Code character letters are enclosed in single quote characters, and are not case-sensitive.|
The HEADING statement prints a header at the top of each page of output text. This output text can be displayed on a terminal (by default) or directed to a printer (by specifying PRINTER ON).
The header can consist of a literal text and code characters that either specify text (for example, include the current date), or control the printing of header text (for example, center the header). A header is always enclosed in double quotation marks. To include letter code characters, enclose them in single quotation marks. To include a literal single quotation mark, double it. For example: "Mary''s Report".
The HEADING operation can be reversed using PRINTER RESET, which resets the heading (and footing) to null.
The optional channel specifies the logical print channel for this output. The range of available values is -1 through 255 (inclusive). If channel=-1, output is displayed on the terminal screen. If channel is not specified, the default logical print channel is 0.
The following are the available code characters that supply header text:
|'D'||Include current date formatted as dd mmm yyyy. For example, 11 Sep 2006.|
|Include current time and date formatted as hh:mm:ss dd mmm yyyy. Time is in 12–hour format with “am” or “pm” appended. For example, 7:45:22pm 11 Sep 2006 .|
|Include current page number, right-aligned. The default alignment is 4 spaces. You can specify a larger or smaller alignment by appending an integer to 'P'. For example, 'P2'. 'PP' prints the page number twice, both right aligned 4 spaces. This code specifies the page number position and alignment; the PAGE statement defines the actual page number value.|
|'S'||Include current page number, left-aligned. This code specifies the page number position and alignment; the PAGE statement defines the actual page number value.|
|'R'||Include record ID, left-justified.|
The 'S' and 'P' code characters specify whether an increasing number of digits (1, 10, 100, etc.) should expand the page number to the left or to the right. These code characters can be included at any point within the text of a header. The page number appears at that point, either left-aligned ('S') or right-aligned ('P'). By default, both 'S' and 'P' are left-justified. To right-justify a page number, use the 'G' code, as follows: 'GS' or 'GP'.
The following are the available code characters that format header text:
|'C'||Center the header. You can adjust centering alignment by appending an integer to 'C'. For example, 'C15'. You can also center a header using the 'G' code character.|
|'G'||Insert spaces to evenly distribute the header across the full available width. You can specify multiple 'G' codes within a header.|
|Line break. Text after line break defaults to left-justified.|
|'N'||Suppress automatic paging.|
|'Q'||Treat \, ], and ^ as literals, not code characters for rest of header.|
By default, a header is left-justified. To right-justify a header, specify a 'G' before the header text: "'G'Annual Report". To center a header, specify a 'G' before and after the text: "'G'Annual Report'G'". To spread out the parts of a header, specify a 'G' between literals in the header: "'G'Annual'G'Report'G'".
By default, the backslash (\), right square bracket (]), and caret (^) are code characters. To include these characters as literals in a header, use the 'Q' code character. Any instances of these three characters following the 'Q' code in the header are treated as literals, not code characters.
To clear an existing heading, specify HEADING CHAR(255). If you specify more than one HEADING statement in a program, MVBasic issues a form feed before executing the second (and all subsequent) HEADING statement(s).
The HEADING statement places text at the top of each page. The FOOTING statement places text at the bottom of each page. The PAGE statement advances printing to the next page and prints any defined heading or footing on that page.
IN2, jBASE, MVBase, PICK, Reality, R83, POWER95, Ultimate: in these emulation modes, the HEADING statement is immediately applied when issued.
D3: The initial HEADING statement is immediately applied when issued. Subsequent HEADING statements are applied following either the end of a page or the issuing of a PAGE statement. This does not apply if PRINTER ON is immediately followed by a PAGE statement, or if a PRINT statement is followed by HEADING.
jBASE: 'PP' includes the page number right aligned 4 spaces.
Reality: 'P' includes the page number with no alignment; 'PP' includes the page number right aligned 4 spaces.
In Caché MVBasic, the HEADING is applied to only the current output device. For example, if you specify HEADING for the terminal page header, then specify PRINTER ON, you must specify HEADING again for the printer page header. In D3, MVBase, and Reality, if you specify HEADING for the terminal page header, then specify PRINTER ON, the terminal header is inherited by printer channel 0.
The following example centers the current date at the top of each page. Note that the header must be enclosed in double quotation marks, even when there is no literal header text:
The following example centers two lines of header, with the page number right-justified on the first header line:
HEADING "'G'Big Widgets Corporation'GS''LC'First Quarter Report"
The following example left-justifies two lines of header, with the page number at the end of the first header line and the time and date at the end of the second header line. Note that the punctuation code characters are not enclosed in single quotes:
HEADING "Big Widgets Corporation^]First Quarter Report \"