Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing on a new page

Status
Not open for further replies.

YGrunt

Programmer
Dec 12, 2002
7
BE
Is it possible to force an end of page without using the linage clausule?

I have a program that reads a number of patients from a file. When there are more than 5 patients, the program has to write 5 patients on one page and then write on another page and so on.

If anyone could help me,thx

YGrunt



 
Yes. Check
Code:
WRITE...AFTER ADVANCING
Tom Morrison
 
It depends on how you are controlling your print lines. If you are using a data item for example LINE-COUNT to control the printing, simply move 66 to LINE-COUNT. This will then force your program to throw a new page from your Print Paragraph/Section.
 
Just use a Patient counter and when it get to be over 5 go to another page and reset it kind of like a line counter for 55 line pages. Often you need a heading on top of the next page so you may have to do that also. If you do not like my post feel free to point out your opinion or my errors.
 
Hi YGrunt,

All the advices you have been getting boil down to the need to do a little planning/design before you code.

In this particular case, you should know how many lines per page you want to print, and how many lines each patient (including all needed headings) generate. You should have a mock-up of your page(s) on hand.

Armed with that information, your program should be quite easy to code, n'est-ce-pas? [wink]

Dimandja
 
Thx everyone for the answers, the new page has been written, the battle has been fought

 
YGrunt,

You missed my point. HOW was the problem solved?

Jack
 
I used a counter to count the lines that I write on the page. Then subtracted it from 65 orso which is the maximum lines on a page.
And then I wrote a number lines which contained spaces equal to the result of the subtraction.

Maybe not the most elegant solution, but it will do

YGrunt
 
Hi YGrunt,

You didn't show us the write stmts you use to print the lines of your report, so I assume you're using the

WRITE AFTER ADVANCING .... form.

Here's the usual algorithm:
Code:
IF PG-LINES-WRITTEN > 65 (or whatever)
   OR
   PG-BREAK-SW-IS-SET
   WRITE RPT-REC 
    FROM RPT-HDR AFTER ADVANCING PAGE
   MOVE 0 TO PG-LINES-WRITTEN 
   ADD 1 TO PG-NBR
END-IF
WRITE RPT-REC 
 FROM RPT-DETAIL AFTER ADVANCING 1 LINE
ADD 1 TO PG-LINES-WRITTEN

The intent of this code is to determine:
1) If the page is full
2) If you previously detected a situation where a new page is required (page break).

If either of these conditions is present, a heading line is printed on a new page and the counters are adjusted before the detail line is printed.

If they aren't, only the detail need be printed.

Notice, there's no need to fill the rest of the page with blank lines; that's what the AFTER ADVANCING PAGE clause is for. It "jumps" to the top of the next page before printing the line.

What I showed here is a "stripped down" version of what you may have to do (e.g., print multiple heading lines, etc.); you might even want to PERFORM a "start new page" pgraph.
But it presents the main idea: you can force a page break "jump" by using the AFTER ADVANCING PAGE clause.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top