Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't use eval or name expression to reference object?
Message
From
07/08/2002 16:13:41
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Can't use eval or name expression to reference object?
Miscellaneous
Thread ID:
00687238
Message ID:
00687238
Views:
43
I know that name expressions and evaluate() executes more quickly than macro substitition. I have seen other posts, faqs on the difference, so I understand ROUGHLy what the issues are. I know that for example that I can use evaluate and name expression when vfp is expecting a name such as mytable or mytable.myfield, and that I can't use it when referencing a portion of a command.

But I don't know where the following scenario fits in, or how to optimize it.

I often read in values from a table to add objects to a form on the fly, with code like this:


lclabelname='l3elbl' + alltrim(curicdltplt.cattribid)
thisform.addobject(lclabelname, 'l3elbl')
thisform.&lclabelname..top=lnRow+lnTopMargin
thisform.&lclabelname..left=lnColumn

Not only am I using macro substitution, but I am repeating it multiple times.

I tried:
thisform.(lclabelname).top=lnRow+lnTopMargin
but I get a syntax error

I tried
thisform.evaluate(lclabelname).top=lnRow+lnTopMargin
but I consistently get a c5 error.

As I I'm writing here I realize that I can write:

oNewreference= thisform.&lclabelname
oNewreference.top=lnRow

and then I only have to do the macro substitution once.


But how can I get rid of it entirely? How can this code be optimized/improved?

TIA
Next
Reply
Map
View

Click here to load this message in the networking platform