Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use of macro substitution
Message
De
09/03/2003 11:35:11
 
 
À
09/03/2003 11:18:23
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00763410
Message ID:
00763435
Vues:
14
Cindy - Thanks - Hard to break old habits sometimes. Thanks for a very thorough explanation. I will try to ween myself from the & and use name expressions in the future. Makes life a lot simplier.

Also a thanks to Glenn for his response.

Gaylen

>Hi Galen,
>
>>I have a form property called thisform.filename initialized to "c:\test\test.dbf"
>>When I run a query using "Select * From &thisform.filename" it errors saying the table is not found.
>
>As Glenn pointed out, you're better off using a "name expression." Name expressions are shown in parenthesis and are always faster than macro expansion. The code would look like
SELECT * FROM (ThisForm.FileName)
You can use a name expression anywhere that VFP expects a name.
>
>From the Macro Expansion Help topic:
>Tip Whenever possible, use a name expression instead of macro substitution. A name expression operates like macro substitution. However, a name expression is limited to passing character strings as names. Use a name expression for significantly faster processing if a command or function accepts a name (a file name, window name, menu name, and so on). For additional information on name expressions, see Name Expression Creation.
>
>>Is it that a form property is not really a variable as far as macro substition is concerned.
>
>When using macro expansion with an object property you use two dots - one is the usual dot and the other denotes that the macro expansion ends "here." The expression would look like:
SCATTER NAME THISFORM.MyProperty
>lcProperty = "MyProperty"
>? THISFORM.&lcProperty..Field1
I tried every combination of your ThisForm.FileName property and "&" and extra dots and always got an error of some sort, but I can't say exactly why it doesn't work.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform