comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: INIT functions... called when?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: INIT functions... called when? [message #19364 is a reply to message #19360] Tue, 07 March 2000 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Steve Allison (sallison@netcomuk.co.uk) writes:

> 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.

Instead of returning the undefined variable TRUE, I'd
return a 1 from your INIT method. That should make things
work better. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hough Transform/Active Contour Algorithms
Next Topic: INIT functions... called when?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 19:19:57 PDT 2025

Total time taken to generate the page: 0.72115 seconds