Re: Generating keyword parameters from strings [message #67446 is a reply to message #67445] |
Wed, 22 July 2009 13:46   |
Eric Hudson
Messages: 19 Registered: June 2006
|
Junior Member |
|
|
Hi,
I guess I was unclear, sorry.
What I mean is that I want to take a string and turn it into a
keyword. So continuing my above example:
function GetProperty, object, propertyName
; The below line is pseudocode -- what I want
object->GetProperty, 'propertyName'=value
; using execute I'd say:
; ok = execute('object->GetProperty, '+propertyName+'=value')
; but I'm wondering if there is another way to do this
; that will work when execute is forbidden
return, value
end
pro TestGet
myObj = obj_new('IDLgrPalette')
myvalue = GetProperty(myObj,'N_COLORS')
; Should be functionally equivalent to
; myObj->GetProperty, N_colors=myValue
end
That is, my 'GetProperty' function has to take the string 'N_COLORS'
and then call the GetProperty method using that STRING as a reference
keyword. It is this functionality that I'm interested in (I'm just
using GetProperty as an example).
Thanks,
Eric
|
|
|