Re: Generating keyword parameters from strings [message #67455 is a reply to message #67454] |
Wed, 22 July 2009 11:00   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Eric Hudson wrote:
> Hi,
>
> Does anyone know of a method of taking a string and turning it into a
> keyword parameter? As an example, say I want to write a function:
>
> function GetProperty, object, propertyName
> object->GetProperty, 'propertyName'=value ; This is pseudocode --
> this line is what I need
> return, value
> end
>
> Obviously I can write this using execute, but I'd prefer to avoid that
> if at all possible.
> Also, although I use the GetProperty method as an example, this is a
> more generic question about generating keyword parameter calls (so,
> for example, David's nice discussion of a general GetProperty method
> http://www.dfanning.com/tips/getproperty.html doesn't help here).
>
> If I were just setting a value this would be easy to do with _EXTRA by
> making my own structure. But for getting values it doesn't seem like
> there is an easy equivalent (it would be nice to just make a
> _REF_EXTRA structure if it behaved equivalent to _EXTRA but it seems
> it doesn't).
?
I use _EXTRA for my Set_Property() methods, and _REF_EXTRA for my Get_Property() methods
when I have superclasses and it seems to work fine. For example:
PRO SUBCLASS::Set_Property, $
....subclass property keywords here...
_EXTRA = Extra ; Keywords passed onto SUPERCLASS::Set_Property
...set the subclass properties....
; Set the superclass properties
self->SUPERCLASS::Set_Property, _EXTRA = Extra
END
PRO SUBCLASS::Get_Property, $
....subclass property keywords here...
_REF_EXTRA = Extra ; Keywords passed onto SUPERCLASS::Get_Property
...get the subclass properties....
; Get the superclass properties
self->SUPERCLASS::Get_Property, _EXTRA = Extra
END
I really don't understand why, in the SUBCLASS::Get_Property method, I can get away with
using the _EXTRA keyword to the SUPERCLASS::Get_Property method, but it works. Go figure.
cheers,
paulv
|
|
|