Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro Substitution with THIS.Property
Message
From
22/07/2000 10:22:51
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00395115
Message ID:
00395871
Views:
8
Nadya,

Aha! You have a very valid point which didn't come through when you posted the code by itself. Spaces within filenames is a new idea to lots of people who are still stuck in the 8-character mode and I'm glad you mentioned it!

I like the suggestion in Hacker's Guide which says that name expressions are preferable to macro expansion or EVAL() for speed. But they can only be used where FoxPro expects a name. For example:
lcMyTable = GETFILE()
USE (lcMyTable) IN 0    && Works with spaces too!
Hacker's also mentions using macro expansion where the expression is used repeatedly because Fox will only have to expand it once where EVAL() will be evaluated each time. Both of these are best avoided in loops where the following would be faster:
lcMyVariable = &MyEvaluatedVariable
FOR x = 1 to Something
    * Do something with lcMyVariable
ENDFOR
EVAL() is still the best to handle special cases like the internal spaces you mentioned.

The trick, which you and I are trying to learn ;-), is to reach for the "best" approach in each situation and to know why that approach is best, and especially the special cases which it may or may not handle.



>One of my colleague uses macro expansion all the times, even in this syntax: use &thetable. It just irritates me, because it theory this syntax would not work, if thetable contains spaces (not our case, though).
>
>Anyway, the point is that it's not necessary to use macro substitution, if there are other ways...
>>>THISFORM.LOCKSCREEN = .T.
>>>IF NOT EMPTY(lGrid)
>>>   local lObject
>>>   lObject=evaluate('THIS.PARENT.'+lGrid)
>>>   lObject.SetFocus()
>>>
Previous
Reply
Map
View

Click here to load this message in the networking platform