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

Home » Public Forums » archive » Is a dynamically sized pointer array object component possible?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Is a dynamically sized pointer array object component possible? [message #66554] Thu, 21 May 2009 14:35
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

I'm trying to create an object with a component that is a pointer array... but I don't
know the size of the array ahead of time. In structure-speak, I'm doing this:

IDL> x={blah,y:ptr_new()}
IDL> x.y=ptr_new(ptrarr(4))
IDL> (*x.y)[0] = ptr_new(dindgen(20))
IDL> help, *(*x.y)[0]
<PtrHeapVar1> DOUBLE = Array[20]

Now, if I knew what size of array I needed in advance (in this example, 4), I could do the
following:

IDL> x={blah,y:ptrarr(4)}
IDL> x.y[0] = ptr_new(dindgen(20))
IDL> help, *x.y[0]
<PtrHeapVar1> DOUBLE = Array[20]

The latter example is preferable since
a) it more closely reflect the data, and
b) the dereferencing is clearer.

I tried to do this:

IDL> x={blah,y:ptr_new()}
IDL> x.y = ptrarr(4)
% Expression must be a scalar in this context: <POINTER Array[4]>.
% Execution halted at: $MAIN$

I (mostly) knew it wouldn't work, but is there a way to do this? Having a pointer to a
pointer array I find..... disconcerting.

In the final application I would have the following procedure,

PRO blah__define
void = { blah, y:some_fancy_definition?.... }
END

and then do something like,

PRO blah::allocate, n
self.y = PTRARR(N_ELEMENTS(n)) ; This causes the heartache.
FOR i = 0, N_ELEMENTS(n)-1 DO BEGIN
self.y[i] = PTR_NEW(DBLARR(n[i]))
ENDFOR
END

to be called thusly:

x = obj_new('blah')
x->allocate([2,5,9,25])

Is it doable? Am I missing another simple fix (ala the FORMAT_AXIS_VALUES function from a
previous thread :o) I would like to avoid the double dereferencing if possible.

Hopefully I've explained myself. Thanks for making it this far.

cheers,

paulv
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: area inside tracings
Next Topic: Re: area inside tracings

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

Current Time: Wed Oct 08 11:39:58 PDT 2025

Total time taken to generate the page: 0.00461 seconds