Re: PAGE x OF y
Posted in 1997
Lenny Vovk (lvovk@opsny.csfb.com) wrote: : I have a requirement from my users to include in : the header of the report my 4gl program produces : the following: : PAGE x OF y : Obviously, it is very easy to include current page : number, my problem is how to calculate total number : of pages in my report. Any help would be greatly : appreciated. I can't think of any really good solutions. The most obvious would be to "select count(*)" the number of rows before starting and calculating how many pages before starting your report. But, this can get tricky if the number of rows varies per page. Sometimes with master/detail data, this may be nearly impossible to do without re-doing all the report logic ahead of time. Which, is another ugly solution. You could write a secondary report that outputs to a temp file. It has all the same logic, page size, etc., except it stores the page number into a global variable on every page trailer. Once you run through the report, you have your number of pages in a global variable. You then delete the temporary file, re-open your cursor and output the report to your real report, using your global variable for total number of pages. It obviously takes more time to do this, and if it's a large report or takes a long time to generate, this isn't feasible. Then, there's the ugly "Secondary program". You output to a temporary file, then have some secondary program that you pass the filename and number of pages. It read the file, and outputs to the printer. Either at n-interval lines, (or maybe you give it a specific tag to look for), it outputs the "Page x of y". This is probably the best solution if the number of pages is hard to calculate. -- __________________________________________________________________________ Joel Schumacher JCPenney Co. - UNIX Network Systems jschumac@uns-dv1.jcpenney.com 12700 Park Central Pl (972) 591-7543 Dallas TX 75251