Re: Generating keyword parameters from strings [message #67445 is a reply to message #67443] |
Wed, 22 July 2009 15:55   |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Eric Hudson wrote:
> 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).
I don't think this is possible without a) using EXECUTE or b) writing a
temporary IDL .pro file. I messed around with the REF_EXTRA keyword to
SCOPE_VARFETCH, but I couldn't get what you wanted.
Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
|
|
|