Re: Object SetProperty Not inherited [message #78870 is a reply to message #78869] |
Wed, 04 January 2012 17:41  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
godber writes:
> Using IDL 8.1 I am having a hard time setting properties on objects as the documentation suggests I can. Using the sample object from the documentation:
>
> PRO myObjectClass__define
> structure = { myObjectClass, $
> PROPERTY1: 0L, $
> PROPERTY2: '', $
> INHERITS IDL_Object $
> }
> END
>
> I then instantiate and try to set a property as follows and I get an undefined method error
>
> IDL> o = Obj_New('myobjectclass')
> % Compiled module: MYOBJECTCLASS__DEFINE.
> IDL> o.property2 = 'foo'
> % Attempt to call undefined method: 'MYOBJECTCLASS::SetProperty'.
> % Execution halted at: $MAIN$
>
> The documentation suggests that subclassing IDL_Object should make using the dot operator possible:
>
> "If your object inherits from the IDL_Object class, you can set or change the object's properties after object initialization by calling the property directly using the dot operator:
>
> Obj.PROPERTY = value, ...
> "
>
> What am I missing?
You have to write the SetProperty and GetProperty methods
for this object class. Then, you can use the "dot" operators
to call the methods like you are doing.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|