Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CLR and VFP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00409695
Message ID:
00412943
Vues:
22
Rick;

I use EVAL() whenever I can but EVAL() can't handle a few things like assignments (ie. the left side of an assigment) and things like full commands.

For assignements the STORE command and name expressions can be used to replace macro expansion many times. I have rarely seen anyone use it that way, but it works. For example...

*=====================================
LOCAL lcVarName, ;
lcStuff, ;
lcTarget

STORE "" TO m.lcStuff, ;
m.lcTarget
m.lcVarName = "m.lcTarget"
m.lcStuff = "Hello"

CLEAR
*Typical way of assigning unknown variable
&lcVarname = m.lcStuff
?m.lcTarget

m.lcStuff = "World"
* Using name expression
STORE m.lcStuff TO (m.lcVarname)
?m.lcTarget
*=====================================

And then there is using name expressions for setting values in tables, which I do see more often, such as...

*=====================================
LOCAL lcFieldName
m.lcFieldName = "cjunk"
create cursor junk( cJunk c(12))
append blank

replace (m.lcFieldname) with "Hello"
insert into junk ((m.lcfieldname)) values ("World")
clear
list
*=====================================

Now stringing together a full command, like building up a SQL statement in a variable and then executing it with macro substitution, I can't think of a way around that.
Jim Munn, MCSD
Visual Data Solutions
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform