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 11:56:47
 
 
To
22/07/1999 00:43:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00244254
Message ID:
00244798
Views:
21
>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?


I have a guess.

set safety is a command that takes no arguments! Actually, there is no SET SAFETY command! There is a "SET SAFETY OFF" command and a "SET SAFETY ON" command. So literal string substitution works, but trying to use a run-time calculated value causes a syntax error.

set date is a command that takes a single argument. That argument may be a constant (a macro evaluates to a string constant, so it's OK) or it may be a run-time evaluated variable.

In other words, the general syntax for SET commands is not a good example of language design. But hey, nobody's perfect.
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform