Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of macro substitution vs. string valued variables
Message
From
21/07/1999 13:33:40
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Use of macro substitution vs. string valued variables
Miscellaneous
Thread ID:
00244254
Message ID:
00244254
Views:
57
Reading through the recent thread #243690 about macro substitution reminded me of the more general question I have about when to use macro substitution as opposed to using a string valued variable.

Until I started working with VFP, my concept of a macro is that it's a parametrically defined literal that is evaluated at compile time. So the concept of macro values being evaluated at run-time was a little alien to me ... in fact, I had to do some experiments to verify for myself that the substitution really occurs at runtime.

That's all fine. It works the way it works and now I know. But I'm still a little unsure as to the actual rules for when one would use macro substitution and when one would use variable substitution. Although I have a general "feel" for when to use one or the other, I do not know the specific rule that governs usage. For example, I know that:
SET EXCLUSIVE $myOffOnStringVariable
Is correct and that
SET EXCLUSIVE myOffOnStringVariable
will generate an error.

Similarly,
myOffOnStringVariable = "ON"
makes sense while
$myOffOnStringVariable = "ON"
Might make sense (haven't tried it). But sure as hell does something different. (I think it would stick "ON" into the variable whose name is contained in myOffOnStringVariable).

Rather than acting like a macro operator, & seems to be acting more like pointer dereferencing in C.

At any rate, though I have a feel for how and when to use macro substitution, I'm not sure how I'd state the specific rules for how and when to use it and I think there might be some cases where using either a macro or string valued variable would be legal but would produce different results.

Is there a basic rule of thumb to go by?
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Next
Reply
Map
View

Click here to load this message in the networking platform