Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I determine scope of an existing variable?
Message
De
17/10/2002 23:50:52
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
17/10/2002 13:40:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00712455
Message ID:
00712702
Vues:
12
>I have begun maintenance work on a large vfp system (converted from 2.6) where the naming conventions of using the first letter for the variable scope and the second letter for the data type are not adhered to. When looking at the code I have no way of knowing the variable scope, unless I trace through lots of code looking for local, private or public declarations. I don't even know if the variable in question is a memory variable or reference to a table column.

You might want to check out the new to 7.0 property _vfp.LanguageOptions for this task. It will at least point list undeclared variables for you, which is a start.

Other than that, I think you'll want to go the route of using LIST MEMORY instead of SAVE TO [a mem file]. I don't see why peformance is too big of an issue, assuming this is a one time analysis tool. In any case, I tried the following example, and the results are different depending on the method you use. Even if you do succeed in parsing the MEM file, it's not certain you'll have the info you need.
CLEAR ALL
CLEAR
PUBLIC xPublic
PRIVATE xPrivate1
xPrivate1 = "xPrivate1"
DoSomething()
?
?"After restoring from .MEM file"
RESTORE FROM TestScope
LIST MEMORY LIKE x* TO TestScopeList
PROCEDURE DoSomething
	xPrivate2 = "xPrivate2"
	xPublic = "xPublic"
	?"From memory"
	LIST MEMORY LIKE x* TO TestScopeList
	
	SAVE ALL LIKE x* TO TestScope
ENDPROC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform