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

Home » Public Forums » archive » Naive pointer question ?
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: Naive pointer question ? [message #29007 is a reply to message #28944] Thu, 24 January 2002 06:53 Go to previous messageGo to previous message
Paul van Delst is currently offline  Paul van Delst
Messages: 364
Registered: March 1997
Senior Member
trouble wrote:
>
> Yo,
>
> Thanks for the input - I've been looking through my IDL library
> looking for routines to adapt for pointers but can't see any very
> obvious candidates (don't need data structures beyond trivial in
> complexity).
> However, one useful app for me is Paul's suggestion for 'a data array
> where each "element" is another array, and each one is a different
> size'. Would I need to store the length of each element in a separate
> array ? And then store both arrays in a structure ?

I don't think that's necessary. A simple example would be (excuse any syntax errors - it's been
a while since I've actually used IDL....):

; -- Define array sizes simply for this example
; -- In real app, array sizes are determined at runtime
array_sizes = [ 10, 2300, 45, 300, 3 ]
n = N_ELEMENTS( array_sizes )

x = PTRARR( n )
FOR i = 0, n - 1 DO BEGIN
x[i] = PTR_NEW( FLTARR( array_sizes[ i ] ) )
ENDFOR

I can then stick data in any particular array and/or check it's length

length = N_ELEMENTS( *x[i] )

etc etc. layering onwards to further complexity as needed. Usually I have structures that
contain pointer arrays to other structures which contain pointer to arrays of varying sizes.
Sounds messy, and sometimes is, but it does make for quite flexible data structures.

Depending on the complexity of your data structure, using an object might be the way to go -
you get a bit more protection wrt to killing/dropping/losing pointer references and a simpler
interface to the data but at the expense of even more complexity (and time designing it all in
your head/on paper).

cheers,

paulv

p.s. Common blocks are not evil. They are unfairly maligned (and misaligned) but should be used
judiciously.... just like GOTOs.

--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: TVCRS and Widgets
Next Topic: Re: Question again :)

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

Current Time: Wed Oct 08 19:25:26 PDT 2025

Total time taken to generate the page: 0.00536 seconds