Re: page 1 of x in 4gl reports ???
Posted in 1996
In article <4vl5b9$6lo@news.icanect.net>, Advanced Server for UNIX user <lee@aishost.astrainfo.com> wrote: >We are constantly being asked to provide reports with PAge 1 of X on >our system. This is fine with simple reports, but with things like >inovices taht may have multiple different type of lines being printed >there is no simple calculation to know in advance how many pages there will >be. Short of pre-processing the whole invoice and then processing again >to print, is there any other easy way to accomplish this?? Well, you could always do something like this.... database mydatabase define n_pages integer main define i integer declare c1 cursor for select cust_id from some_table start report rpt_dummy to "/dev/null" start report rpt_real to "rpt_real.out" foreach c1 into i output to report rpt_dummy ( i ) output to report rpt_real ( i ) end foreach finish report rpt_dummy finish report rpt_real end main report rpt_dummy(x) define x integer order by x format page header print "page ", pageno, " of ", n_pages let n_pages = pageno #### <---- additional line in rpt_dummy on every row print x end report report rpt_real(x) define x integer order by x format page header print "page ", pageno, " of ", n_pages on every row print x end report Note that "rpt_dummy" is an exact copy of "rpt_real", but with the extra line "let n_pages = pageno" in its page header. We pass the records to both rpt_real and to rpt_dummy. Because we finish rpt_dummy first, and because the report contains an "order by", the whole of rpt_dummy is processed before any of rpt_real is processed. When rpt_dummy is finished, n_pages contains the value of the highest page number ever reached. The "finish rpt_real" then causes all of rpt_real to be processed: this can access the value of n_pages since it has module-scope. I hope this makes some sort of sense and can be adapted for your purposes. Basically I am pre-processing the whole report before printing any of it; I'm just letting 4gl do all the hard work. Paul ************************************************************************* Disclaimer: All opinions expressed in this message are well-reasoned and insightful; needless to say, they are not those of Informix Software, its partners or lackeys. Anyone who says otherwise is itching for a fight.