Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of macro substitution vs. string valued variables
Message
From
22/07/1999 12:02:47
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
 
 
To
22/07/1999 00:43:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00244254
Message ID:
00244802
Views:
20
>Hi David,
>
>Thank you very much for the wonderful explanation, which made a lot of fuzzy things clear after all these years. However, after playing in the command window for a while, something new begin to puzzle me…
>
>I am not surprised by the following:
>coldsafety = set("safety")
>set safety &coldsafety && Working
>set safety (coldsafety) && NOT Working
>set safety eval("coldsafety") && NOT Working
>

>
>However, I am surprised by:
>colddate = set("date")
>set date &colddate && Working as usuall
>set date (colddate) && WOKING!!!
>set date eval("colddate") && WOKING!!!
>

>
>What are going on here?
>
>
>Chen
>

Chen,
Some set commands, like SET SAFETY ON/OFF and SET TALK ON/OFF are compiled into tokens. SET TALK ON is diferent from SET TALK OFF. Others, like SET DATE are compiled into a token and a name. If you look into an fxp containing "SET DATE FRENCH" and "SET DATE AMERICAN" you will see a token followed by FRENCH or AMERICAN. These are passed to the interpreter at run-time. The compiler has a list of valid names, so if you put "SET DATE ColdDate" in your code, the compiler will tell you there is a syntax error. The compiler *will* accept a Name Expression here, though. If you look in the fxp, you will see that "SET DATE (coldDate)" or "SET DATE EVAL(ColdDate)" compiles into a token for the command and a token referencing a variable list. This seems to tell the interpreter to resolve the name on the fly.
A disclaimer should go here... I have no inside knowledge of the compiler or interpreter, just assumptions based on the FoxPro documentation, and years of trying code and looking into the fxps attempting to figure out "why does it do that?"

By the way, here is how to find code in an fxp. Since macros are stored uncompiled, put a macro before and after the line you want to check, then you can find it in the fxp. Looks like this...
&BEFORE CODE
SET DATE FRENCH
&AFTER CODE
David.
(Hey, I think I'll sent that "tip" to FoxPro Advisor)
David.
Previous
Reply
Map
View

Click here to load this message in the networking platform