× 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.



If the maximum number of lines printed on the header page is fixed,
and the maximum lines on all continuation lines is also fixed, and you
always keep printing until the maximum on any given page is reached,
then yes, absolutely, you can reliably (and reasonably simply)
calculate the total number of pages.

If the situation is anything more complicated than that, though, you
may need to resort to Alan's (and Helge's) suggestion of doing a full
dry run to get the total number of pages, and then a second run "for
real".

Further responses in-line:

On Tue, Oct 21, 2014 at 11:19 AM, Bill Howie <blhowie66@xxxxxxxxx> wrote:
The "header" page
prints mostly heading information and one or two detail items.

One *OR* two? So are you saying the maximum lines on the header page
is variable? If you can't know ahead of time what the maximum lines
are on the header page, then of course you can't reliably calculate
the total pages ahead of time.

Does each detail item take up exactly one line? If not, then of
course it gets either complicated or impossible to calculate total
pages ahead of time.

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

Why subtract an extra 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

You don't have an "else" clause to handle the case where all the items
fit on the header page, in which case the total pages is 1.

This works sometimes, and sometimes it doesn't.

Are you sometimes too low and sometimes too high? Are you ever off by
more than 1?

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).

Well, other than accounting for the header page, it *should be* as
simple as dividing by the line capacity of the continuation page.
Which is exactly what it looks like you've tried to do, except for the
weird extra subtract by 1.

What do you get if you don't do the extra subtraction? Can you post
actual code instead of verbal pseudocode? Maybe you've mistranslated
your logic into code?

John

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.