INIT functions... called when? [message #19365] |
Tue, 07 March 2000 00:00 |
Steve Allison
Messages: 1 Registered: March 2000
|
Junior Member |
|
|
Hi,
I'm just starting out with IDL and am having trouble creating objects, their
INIT methods don't seem to get called. Here a simple example of what I'm
doing:
<All in "TestClass.pro">
PRO TestClass1__define
struct = {TestClass1, number:0L}
END
FUNCTION TestClass1::init, arg
print, 'Initializing'
self.number = arg
RETURN,TRUE
END
PRO TestClass1::show
print, 'Number is', self.number
END
PRO TestClass1::set, arg
self.number = arg
END
Nothing staggering there... Anyway, I load this file into IDLDE, compile it
(it seems to compile without any complaints), and try to create objects
with:
IDL> p = OBJ_NEW('TestClass1',65)
Which in my book should set the field 'number' to 65. But...
IDL> p->show
gives:
Number is 0
So clearly INIT isn't being called (the message 'Initializing' doesn't show
either). I can change the value of 'number' using TestClass1::Set, and that
seems to work fine - it's just the INIT method I'm having trouble with. Why
isn't it being called? The documentation seems to say that it should be
called automatically when I call OBJ_NEW.
Thanks for your help...
Steve
--
Stephen Allison
sallison@netcomuk.co.uk
|
|
|