Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use of macro substitution
Message
De
09/03/2003 11:18:23
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
 
 
À
09/03/2003 09:03:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00763410
Message ID:
00763432
Vues:
12
This message has been marked as the solution to the initial question of the thread.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform