Previous Topic: Creating Page BreaksNext Topic: Listing Several Reports in One Application Run


Controlling Page Breaks in a Report

The printer setup automatically controls the number of lines printed on the page. If a different specification is necessary, it must be handled procedurally. That means the procedure must count the number of lines generated (that is, the number of LIST statements) and specify LIST NEWPAGE as needed to force pagination.

SET LINE‑CTR = 1
LIST NEWPAGE
FOR EACH CUSTOMER
   IF LINE‑CTR > 55
       LIST NEWPAGE
       SET LINE‑CTR = 1
   ENDIF
   LIST CUSTOMER.CUSTID CUSTOMER.NAME
   SET LINE‑CTR = LINE‑CTR + 1
ENDFOR
LIST NEWPAGE

This example limits the output to 55 lines per page. Notice that a working data variable, LINE‑CTR, was defined to act as a counter.