Using a variable to reference an object property
Anyone know if it's possible using cache objectscript (or something else maybe) to reference an object property using a variable? For example:
s obj={}
s obj.prop1="hello"
s var="prop1"
w obj.var <== which would result in a reference to obj.prop1 and write out "hello"
Comments
The following will work for you:
w obj.%Get(var)
works like a charm! Thanks!!
Also:
w $property(obj,var)
Also works like a charm!!
x "w o."_var
No, no - *please* don't encourage the the use of eXecute ... that can make maintenance so very difficult :( Most ObjectScript coding standards I have seen strictly forbid the use of this :)
I'm not encouraging. I wouldn't use execute here but i would also encourage developers to know what execute is and why not to use it in most circumstances.