Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of macro substitution vs. string valued variables
Message
From
23/07/1999 06:34:06
David Fluker
NGIT - Centers For Disease Control
Decatur, Georgia, United States
 
 
To
23/07/1999 03:47:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00244254
Message ID:
00245220
Views:
22
>Hi all three Davids,
>
>There is more fun, after I upgrade to VFP 6.0 I found I need to do something with the command set collate, here is what I found:
>
>coldcollate = set("collate")
>set collate to &coldcollate && NOT WORKING
>set collate to coldcollate && WORKING

>
>It seems that there are no consistency in the VFP SET command at all.
>
>Chen
>
>

You're right, the set commands are not at all consistent. I checked help and found the collate syntax was SET COLLATE TO "DUTCH" or SET COLLATE TO "MACHINE", etc. So this SET command takes a string parameter! So to make your macro line work, you need to enclose it in quotes.
SET COLLATE TO '&cOldCollate'
The second example SET COLLATE TO cOldCollate works because cOldCollate is already a character variable.
I guess the best thing to do with SET commands is check the syntax and make your best guess!



>
>>>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.
David.
Previous
Reply
Map
View

Click here to load this message in the networking platform