Re: dereferencing a pointer to an object array [message #32787] |
Fri, 08 November 2002 15:38 |
Pavel A. Romashkin
Messages: 531 Registered: November 2000
|
Senior Member |
|
|
I think David is right. Try stepping into the loop in your debugger, and
make sure your Obj_New returns valid objects and populates the array.
One thing that draws my attention here:
> self.ZoneGroupObjs = ptr_new(ZoneGroupObjs)
You only do this once per session, right?
Cheers,
Pavel
Brent Griffith wrote:
>
> greetings,
>
> What is the trick to dereferencing a pointer to an Object array? I
> want to keep track of an array of object references in another object.
> I don't know how many until runtime so I use a pointer to the object
> array and store that in the managing object. But when I go to access
> the thing, by dereferencing the pointer, the object array has the
> right size but all the objects are null.
>
> here is how I create and store the object array
>
> ZoneGroupObjs = objArr(self.numGroups)
> For i = 0, self.numGroups-1 do begin
> ZoneGroupObjs[i] = obj_new('ZoneGroup')
> endfor
> self.ZoneGroupObjs = ptr_new(ZoneGroupObjs)
>
> Then to access the objarr inside another method..
>
> theseGroupObjs=*self.ZoneGroupObjs
>
> But it doesn't work! Why?
>
> Thanks!
>
> Brent
|
|
|
Re: dereferencing a pointer to an object array [message #32804 is a reply to message #32787] |
Thu, 07 November 2002 16:12  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Brent Griffith (Brent_griffith@nrel.gov) writes:
> What is the trick to dereferencing a pointer to an Object array? I
> want to keep track of an array of object references in another object.
> I don't know how many until runtime so I use a pointer to the object
> array and store that in the managing object. But when I go to access
> the thing, by dereferencing the pointer, the object array has the
> right size but all the objects are null.
>
> here is how I create and store the object array
>
> ZoneGroupObjs = objArr(self.numGroups)
> For i = 0, self.numGroups-1 do begin
> ZoneGroupObjs[i] = obj_new('ZoneGroup')
> endfor
> self.ZoneGroupObjs = ptr_new(ZoneGroupObjs)
>
> Then to access the objarr inside another method..
>
> theseGroupObjs=*self.ZoneGroupObjs
>
> But it doesn't work! Why?
This is really off the wall, but I'll bet it doesn't
work because you are forgetting to return a 1 from
your INIT method. (Maybe your INIT method is a procedure
instead of the required array.) But there is nothing
wrong with the code. Look elsewhere. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|