ColumnWidths

_PageNo

This variable is that rare bird—a system variable that works in the most up-to-date way of getting output, but not very well in the older, obsolete ways. It contains the current page number and can be used to put the page number on a report. Although you can use it with ? and ?? output, _PageNo's value there is based solely on the number of lines output and _PLength—it doesn't notice when you issue EJECT (though EJECT PAGE does properly update _PageNo). With @..SAY output, we can't get anything sensible from _PageNo.

Usage

_PAGENO = nPageNumber
An often-asked question is, "How do I put 'Page X of Y' on my report?" The Report Writer doesn't support this natively, but you can use _PageNo to create a workaround. First, set up a variable or property to store the total pages in the report (remember, it must be in scope while the report runs). Initialize it to 0, then put it into your report's footer after the page number, in the "Page X of Y" format. When you run the report, you'll do it twice, first with the NOCONSOLE and TO FILE options. When it finishes the first pass, store the value of _PageNo to the variable or property. Now run it again to its normal destination, and the total number of pages properly displays on the report.

Example

* To implement Page X of Y on a report, you * might use the following expression: "Page "+LTRIM(STR(_PAGENO))     * In the report footer, use an expression like the following: "Page "+LTRIM(STR(_PAGENO))+" of "+LTRIM(STR(nTotalPages)) * Then run the following code: PRIVATE nTotalPages REPORT FORM MyReport TO FILE Temp.RPT NOCONSOLE DELETE Temp.RPT NTotalPages = _PAGENO REPORT FORM MyReport TO PRINT

See Also

Eject Page, _PLength, Report


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net