The PAGENUM option holds the current page number of output. You can use PAGENUM with PAGEPRG to produce the page number on each page of a report. The PAGENUM option is meaningful only when PAGING is set to
YES and only for output from statements such as REPORT and LISTNAMES.
PAGENUM = n
INTEGER expression that specifies the page number to use for the next page of output. The default is
When you are sending output to the default outfile, set both PAGENUM and LINENUM to 1 whenever you want to produce a report starting on page 1. You can set these options in the initialization section of your report program. When you use an OUTFILE statement to send output to a file, PAGENUM is automatically set to
The value of PAGENUM is incremented automatically when the last line of output has been generated on a page. When you set PAGENUM when an output page is only partially full, the value of PAGENUM will be incremented by 1 before the next page is produced. This means you usually have to set PAGENUM to a value of one less than the number you want to show on the following page.
When you set PAGING to
NO, PAGENUM stops counting and keeps its last value. When you reset PAGING to
YES, PAGENUM resumes counting at the page number where it left off.
When you use an OUTFILE statement to direct output to a file, PAGENUM is set to
1 for the file. When you use an OUTFILE statement with the EOF keyword to redirect output to the default outfile, PAGENUM will contain the number that it last held for the default outfile.
Suppose you want each page of a report to have a standard running page heading and a custom title, and pages after the first page to also have the heading "(Continued)". You can define a page heading program called
report.head that uses the PAGENUM value to determine when to add the "(Continued)" heading.
DEFINE report.head PROGRAM PROGRAM STDHDR BLANK PAGING = YES HEADING WIDTH LSIZE CENTER 'Annual Sales Report' BLANK IF PAGENUM GT 1 THEN HEADING WIDTH LSIZE CENTER '(Continued)' BLANK END
In your report program, set the PAGEPRG option to use the
PAGEPRG = 'report.head'
When you run the report program, each page after the first page starts with a heading such as the following.
15JAN95 15:05:16 Page 2 Annual Sales Report (Continued)