Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Can't use eval or name expression to reference object?
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement