Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Assigning value to property of object indirectly
Message
From
21/11/2015 10:00:38
 
 
To
21/11/2015 08:35:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 8.1
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01627690
Message ID:
01627728
Views:
51
>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
;-)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform