[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Proportion fonts and page counting



According to the language reference, use of last-page() will cause the
output to be buffered internally until the references can be resolved, and
only then will it be written to file. In other words, there is some
performance impact, but not nearly as much as running the report twice.

Hope this helps.

Paul.

-----Original Message-----
From: Johnson, Dan [mailto:Dan_Johnson@WRIGHTEXPRESS.COM]
Sent: Thursday, December 16, 1999 6:51 PM
To: SQR-USERS@list.iex.net
Subject: Re: Proportion fonts and page counting


Is it true that when you use the last-page command your program essentially
runs twice. I was told that this is because SQR uses the first run to
calculate the number of pages necessary and then uses the second to actually
produce the reports. Can anyone confirm this?

Dan.

        Ray said

        Paul,

        Here's a slight improvement overy my previous program.
        In addition to all the other monkey business, this one
        also shifts the "Page x of" to the _right_ a little
        by left padding it with a space if the page number is
        greater than 9.  This adjusts the space between the
        "of" and the number of pages to adjust for the narrow
        width of the additional digits in the proportional font.


           #define DEFAULT_FONT 3

           begin-program
           do main
           end-program

           begin-footing 3
           alter-printer font=5
           let $s = 'Page ' || edit(#page-count,'888') || ' of'
           if #page-count > 9
              let $s = ' ' || $s
           end-if
           print $s (2,30)
           if #page-count > 99
              last-page (,39) '' ''
           else
              if #page-count > 9
                 last-page (,38) '' ''
              else
                 last-page (,37) '' ''
              end-if
           end-if
           alter-printer font={DEFAULT_FONT}
           end-footing

           begin-procedure main
           move 872 to #last-page
           alter-printer font={DEFAULT_FONT}
           print 'Hey' (10,10)
           new-page
           move 63 to #page-count
           print 'Howdy' (10,10)
           new-page
           move 321 to #page-count
           print 'Hey' (10,10)
           end-procedure

        Ray
        > Paul,
        >
        > This is a bit of a hack, but it's the only way I can think of
        > solving the problem of incorrect spacing when using proportional
        > fonts with the sequence:
        >
        >    page-number (2,30) 'Page '
        >    last-page () ' of ' '.'
        >
        > The problem is that there is extra space before the numbers,
        > and if the font is a narrow font, there may be extra space
        > after the numbers as well.  The result is that things look
        > a little like this
        >
        >    Page   246    of   398   .
        >
        > instead of this
        >
        >    Page 246 of 398.
        >
        > My solution is to format as much as I can using a single
        > string.  For this I use
        >
        >    let $s = 'Page ' || edit(#page-count,'888') || ' of'
        >
        > to get "Page 246 of" as a string, which I print at
        > the desired location.  Then, I use LAST-PAGE to print
        > the rest of the string, but I shift it to the right an
        > amount that depends on length of the current page number.
        > Finally, I simply omit the trailing period since I can't
        > quite control it's placement (without going to a very
        > small grid size).
        >
        > Here's a simple program which demonstrates the solution:
        >
        >    #define DEFAULT_FONT 3
        >
        >    begin-program
        >    do main
        >    end-program
        >
        >    begin-footing 3
        >    alter-printer font=5
        >    let $s = 'Page ' || edit(#page-count,'888') || ' of'
        >    print $s (2,30)
        >    if #page-count > 99
        >       last-page (,39) '' ''
        >    else
        >       if #page-count > 9
        >          last-page (,38) '' ''
        >       else
        >          last-page (,37) '' ''
        >       end-if
        >    end-if
        >    alter-printer font={DEFAULT_FONT}
        >    end-footing
        >
        >    begin-procedure main
        >    alter-printer font={DEFAULT_FONT}
        >    print 'Hey' (10,10)
        >    new-page
        >    move 63 to #page-count
        >    print 'Howdy' (10,10)
        >    new-page
        >    move 321 to #page-count
        >    print 'Hey' (10,10)
        >    end-procedure
        >
        > Hope this helps.
        >
        > Ray
        >
        > > I am trying to produce the text "Page x of y." as part of a
footing.
        > > However, as this forms part of a customer invoice, I also wish
to use a
        > > proportional font "to make it look pretty".
        > >
        > > I'm aware that the normal advice when using proportional fonts
is to build
        > > the full string before printing, but this does not seem possible
if using
        > > the internal last-page() function to determine 'y' above ('x' is
OK as I can
        > > use #page-count instead of the page-number() function).
        > >
        > > It would seem to me that the only solution is to avoid using
last-page() and
        > > do the work myself by printing a placeholder which I replace in
a
        > > post-processing phase.
        > >
        > > As you can imagine, I would rather do not do this, so if I'm
missing a trick
        > > somewhere, please let me know.
        > >
        > > TIA.
        > >
        > > Paul.
        > >
        >
        >
----------------------------------------------------------------------
        > Ray Ontko   rayo@ontko.com   Phone 1.765.935.4283   Fax
1.765.962.9788
        > Ray Ontko & Co.   Software Consulting Services
http://www.ontko.com/
        >


----------------------------------------------------------------------
        Ray Ontko   rayo@ontko.com   Phone 1.765.935.4283   Fax
1.765.962.9788
        Ray Ontko & Co.   Software Consulting Services
http://www.ontko.com/