× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Bill,

Best and most reliable way of getting the Y figure is by simulate a printout
without actually writing the PRTF lines and just counting the page number.

After the simulate printing restart with actual printing using the counted
page number as Y.

This technique depends on how you obtain the page number, either counting by
the program
or using the infds for the PRTF. The last of course require actual printing
and in this case
you would have to delete the created spoolfile before recreating with Y.


Brgds
Helge

-----Oprindelig meddelelse-----
Fra: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] På vegne af Bill Howie
Sendt: 21. oktober 2014 17:20
Til: RPG programming on the IBM i (AS/400 and iSeries)
Emne: How to reliably determine total pages

Hello all,

I'm working on a program that generates a report which includes a "Page X of
Y" description in the corner. I'm struggling trying to get the total number
of pages to reliably be calculated. I'll try to explain how it works now.
The program does the "two-loop" approach where it reads through all the
items it will eventually print to try to calculate a total number
of items. I believe this part of it to be working correctly (but I could
be wrong).

At the end of this first loop it attempts to calculate the total number of
pages. I'll preface this by saying that this report basically has what
I'll call a "header" page and a "continuation" page. The "header" page
prints mostly heading information and one or two detail items. Then the
"continuation" page just prints detail items. Here's how the calculation
currently works:

if total number of lines > max allowable lines on "header" page then total
lines = total lines - (total lines - max allowable on "header")
- 1
total pages work field = (total lines/max allowable lines on continuation
page)
if the decimal portion of the total pages work field > 0 total pages = whole
portion of the total pages work field + 2 else total pages = total pages
work field + 1 endif endif

This works sometimes, and sometimes it doesn't. It doesn't appear to be
as simple as just dividing the total number of lines by the maximum per
page, because we have two different maximums (because of the whole "header"
and "continuation" thing).

Hopefully this isn't COMPLETELY confusing. Anyone out there know of a
really reliable formula for computing this when two different max lines
amounts are involved? As always any help is appreciated. Thanks!

Bill
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.