Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can't use eval or name expression to reference object?
Message
De
07/08/2002 18:58:23
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00687238
Message ID:
00687292
Vues:
14
Yep. That does the trick. Thanks as always!!


>Try
loObj = EVAL("thisform." + lclabelname)
>WITH loObj
>  .top = lnRow+lnTopMargin
>  .left = lnColumn
>  .Caption = "MyLabel"
>ENDWITH
>
>
>
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform