Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Page n of m from a program
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
00854111
Message ID:
00854132
Vues:
44
You don't need to use the variable in the report -- and you can document what you are doing properly.

Just force a performance-oriented first pass yourself, the way we used to do it (which still works) before there was such a thing as _pagetotal. I'll show you how, below.

Caveat: it's a long time since I've written code like this, and I'm going to put in the window techniques from memory, for the sake of completeness. You may have to adjust them, for example use form object references as needed instead of WOUTPUT()/WONTOP(). Either way, the basic idea will be the same.

ALso for completeness, I've added params for the report name and clauses to this wrapper program, because pretty much everybody has some sort of generic report dialog to execute report form statements -- I'm just using the params to represent *whatever* it is you do of this nature <s>.

To make use of this technique, your report expressions should look like this:
"page "+_pageno + " of "+transform(myvar)
... where myvar is the variable declared in the calling program, or a member of your app object, or whatever you prefer to use.

You also have the opportunity, in the calling program, to do the same thing that Fox does: you can decide that, under certain circumstances, you don't want to do the first pass and don't care about the page total -- in this case your calling program just initializes your var to a dummy value or whatever you like, just as Fox does with _pagetotal.

If you do it this way, your putative developer who doesn't understand the expression within the report will immediately get an error if s/he changes it or gets rid of the calling program -- not such a danger really, it's like anything else now for maintenance programmers, not a "special case" because it is an FRX <s>.
LPARAMETERS the_report, the_clauses

* this program is used to
* execute reports that require
* a page total.
* [... continue doc'ing here,
* explaining that the variable
* declared here is used in report
* expressions ... ]

LOCAL currwind
currwind = WONTOP()

PRIVATE myvar 
* doesn't have to be a private var, 
* could be a property of a global 
* object, for example myapp.myvar

myvar = 0

DEFINE WINDOW x FROM 1,1 TO 20,20
ACTIVATE WINDOW x NOSHOW

REPORT FORM (the_report) &the_clauses
* do it with the NOSHOW window rather than NOCONSOLE
* because under certain conditions 
* NOCONSOLE won't give you the right page count
* -- also it is fast this way

* at this point both _pagetotal and _pageno are the correct 
* value, so you can do this:
myvar = _pagetotal
* or myvar = _pageno, same thing really

RELEASE WINDOW x
IF EMPTY(currwind)
   ACTIVATE SCREEN
ELSE
   ACTIVATE WINDOW (currwind)
ENDIF

REPORT FORM (the_report) &the_clauses TO PRINT
>L<
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform