Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variables - Private vs. Local
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00882138
Message ID:
00883769
Vues:
14
>Do most developers define all the variables at the beginning of a routine, or declare them local as they are defined?

Dunno about most, but since locals are already initialized I declare them in 1 line for perf reasons.
If I need privates, I write one line for each type and initialize a copy of this line with the correct type like:
local lnbla, lcbla,...
private pcTxt, pcMyStr
Store "" To pcTxt, pcMyStr
private pnWhy, PnSee
Store 0 To pnWhy, PnSee
for me this is the best compromise of speed and safety.

>Also, is there a way to tell VFP to REQUIRE variable declarations?
No. You could simulate it just using object properties, but that would slow it down considerably.

> But if VFP could generate an error upon using an undeclared variable I'd catch that (hopefully) the first or second time I ran the routine.
No such luck. But I remember a lint-like tool for vfp - no idea how good it was or where I saw it.
A "option explicit" would make (more) sense if vfp would use different datatypes for int and real memvars.

my 0.02 EUR

thomas
I tend to define variables and names as I go through the programming process and don't know if I'll always remember to add the local declarations each time I create a new variable. >
>Thanks again for your response.
>
>- Dean
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform