How to print "Page 1 of 4" on every report page without a third-party template

Applies to: posted in the Clarion 6 group (public.clarion6); the thread names no template chain.

Problem

The poster wanted every page of a report to show the total page count, for example "Page No: Page 1 of 4", "Page No: Page 2 of 4". The total is not known while the first page is being printed. He wanted to do it without a third-party template. His report was an invoice of one to five pages.

Solution

Two do-it-yourself ways were described.

  1. Print twice. Generate all pages without actually printing them, count the pages at the end and store the count in a variable. Then print again, using that variable (the thread calls it VAR:TotalNrOfPages) as the total. The poster said this is not much extra time when the report is not very long, and called it a good idea.
  2. Put a token into the report, intercept the report after all pages are generated for the preview, and search and replace the token on each page with the final text.

The first reply pointed to a low-priced third-party Page-of-Page template instead and advised buying it rather than coding the token approach.

Caveats

  • The poster did not say which way he finally used.
  • One reader bought the template and reported multi-language "Page x of y" texts working after a small change to the template and two new variables in his app.
  • A reader using a report tool from another vendor, which has its own page-of-page, asked about combining its page variable with his own code; the thread has no answer.

Today (2026)

Not re-tested. The printing-twice idea depends only on the report generating its pages first, so it likely still applies; check how your current report output and previewer behave.

Sources: Sha-Sho (Aug 2006, the question), Charles E. (Aug 2006), Wolfgang O. (Aug 2006), Jean-Pierre G. (Aug 2006), Sukhendu B. (Aug 2006), John S. (Aug 2006) in softvelocity.public.clarion6.