Creating Page Headings and Footings

This section provides an overview of the heading and footing code example and discusses how to:

  • Add page headings.

  • Add page footings.

Here is an example of the code that is required to add a page heading and footing to a program:

Program ex2a.sqr
begin-program
   print 'Hello, World.' (1,1)
end-program
begin-heading 1
   print 'Tutorial Report' (1) center
end-heading
begin-footing 1
   ! print "Page n of m" in the footing
   page-number (1,1) 'Page '
   last-page   () ' of ' 
end-footing

The output for the ex2a.sqr program is:

Tutorial Report
Hello, World.
Page 1 of 1

Note: The PRINT command places text in memory, not on paper. SQR for PeopleSoft always prepares a page in memory before printing it to paper, creating the body first and then the HEADING and FOOTING sections. In this example, Hello, World is run first, followed by Tutorial Report and Page 1 of 1.

Define a page heading in the HEADING section. Begin the section with a BEGIN-HEADING command and end it with an END-HEADING command. Follow the BEGIN-HEADING command with a number that represents the number of lines that are reserved for the heading. (In this example, 1 indicates a heading of one line.)

In the heading and footing sample program, the heading uses exactly one line and contains the text Tutorial Report. The CENTER argument ensures that the text is centered on the line.

Define the page footing in the FOOTING section. Begin the section with a BEGIN-FOOTING command and end it with an END-FOOTING command. Follow the BEGIN-FOOTING command with a number that represents the number of lines that are reserved for the footing. (In this example, the 1 indicates a footing of one line.) This line consists of the text Page 1 of 1.

Adding Comments

Precede comments with an exclamation mark. The comment extends from the exclamation mark to the end of the line.

In the heading and footing sample program, the first line in the FOOTING section is a comment.

To print an exclamation mark , enter it twice to indicate that it is not the beginning of a comment. For example:

print 'Hello, World!!' (1,1)

Adding Page Numbers

Use the PAGE-NUMBER command to print the text Page and the current page number. Use the LAST-PAGE command to print the number of the last page, preceded by the word of, which is bracketed by spaces.

In the headings and footings code example, Page 1 of 1 appears because only one page exists.

Indicating the Print Position

Include numbers in parentheses following the PRINT, PAGE-NUMBER, and LAST-PAGE commands to indicate the position for printing. Express a position in SQR language with three numbers in parentheses: line number, column number (character position), and width of the text.

In many cases, a position contains only the line and column numbers. The width is normally omitted because it is set by default to the width of the text that is being printed. If you also omit the line and column numbers, then the print position is set by default to the current position, which is the position following the last printed item.

In the heading and footing sample program, the LAST-PAGE command has the position (), so the current position is the position following the page number.

The print position is a point within the area of the page or, more precisely, within the heading, body, or footing. The position (1,1) in the heading is not the same as the position (1,1) in the body. Line 1 of the body is the first line following the heading. In the program, the heading has only one line, so line 1 of the body is actually the second line of the page. Similarly, line 1 of the footing is at the bottom of the page. It is the first line following the body.