Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Assigning value to property of object indirectly
Message
De
21/11/2015 10:00:38
 
 
À
21/11/2015 08:35:06
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01627690
Message ID:
01627728
Vues:
50
>Use EVAL() to turn the name of an object into an object reference:
>
>
oSavedObject = EVAL(m.tcObjectName)
>
>You probably want to wrap that in TRY-CATCH in case the object doesn't exist.
>You can then use EVAL again to reference the property:
>
>
>STORE m.tuValue TO EVAL("m.oSavedObject." + m.tcProperty)
>
>
>Of course, it's easier to just pass the object in the first place.

Sorry, no! Treat your CPU well!
store m.toValue to (m.tcObjectName + "." + m.tcProperty) is enough, no need for 2 eval() calls - perhaps try catch, but nothing else
If oSavedObject = EVAL(m.tcObjectName) works, as the name is in scope and not somewhere in a hierarchy, the store will work as well, provided the property exists
;-)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform