On Wed, Aug 13, 2014 at 7:52 PM, Gene Wirchenko <[email protected]> wrote:
>
> For this sort of playing around with text to create source, I tend to
> use & which is usually apostasy or something around here. It is amusing
> that I am posting about another approach after all of the & suggestions.
>
"Apostasy" is a little strong, but the & macro expansion can be thought of
in-line parsing and compilation. It's the "heaviest" of commands to use, as
it requires the most CPU power. However, between the incredible
optimizations the Fox Team put into it, and the evolution of CPU power,
it's rarely the pariah it used to be, unless you're using it in a long and
tight loop.
A strong preference based on decades of experience expressed as strong
opinion can be mistaken for superstitious taboo. And there are surely some
"cargo cult" practices in VFP. Some Fox traditions have been eclipsed by
improvements and bug fixes in the language and engine.
In addition to its intensive use of CPU, the & macro expansion also has
several sharp edges: the command will execute whatever commands it is
given, so unsanitized user input at the wrong point ("ZAP") can be the
language-level equivalent of SQL injection. In addition, it creates the
phenomenon of "executing code that isn't there," iow, code that can't be
found with a Code References or other search, making maintenance and
debugging a challenge.
So, when I say, "Use & as the last resort and only when it's appropriate,"
I've given it some thought.
> You could use evaluate():
>
> what="imf"
> theobj=evaluate("thisform.txt"+what)
> theobj.value=evaluate("myobj."+what)
> theobj.refresh()
>
Likely more efficient. Whether that makes a difference in the application
is something worth testing, if the OP cares.
Saving the refresh()es to the end and wrapping a THISFORM.Refresh() inside
a LockScreen might also speed things up, depending on how many fields need
updating and the sluggishness of screen repaints.
> If you want the proper way, I suppose you could use proper(). <BEG>
>
The great thing about FoxPro is that there are so many ways to achieve
things. Or no way at all.
--
Ted Roche
Ted Roche & Associates, LLC
http://www.tedroche.com
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/cacw6n4u-z3gxazsi24zwokfhtzqpl2rgw2gtklsh9zjrjb-...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.