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

Home » Public Forums » archive » Re: IDL: Structure of Structures?
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
Re: IDL: Structure of Structures? [message #13903] Tue, 05 January 1999 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Scott Norton (norton@optics.rochester.edu) writes:

> Is it possible to create structure of structures?

I'm not sure this question goes with the following example. :-(

> If I have
> NAMEADDRESS = CREATE_STRUCT('name','', 'address', 0.0)
> NAMEADDRESSARRAY= replicate(NAMEADDRESS,100)
> and then wanted a structure that, for instance, that had US states with
> related fields and the above structure as a sub-structure, how would it
> appear?
>
> For instance,
>
> locationUSstate = CREATE_STRUCT(USstate,' ', numberOfvisits,0.0,
> NAMEADRESSARRAY, XX)
>
> so basically there would be a name-address list for each US state...
>
> What should XX be?

I'm going to guess that XX should be what you are calling
NAMEADDRESSARRY, a vector of structures:

locationUSstate = CREATE_STRUCT(USstate,' ', numberOfvisits,0.0, $
NAMEADRESSARRAY, NAMEADRESSARRAY)
(locationUSstate.nameaddressarray[4]).name = 'David'
(locationUSstate.nameaddressarray[4]).address = 4.0

> Is it possible to do this?

Well ... yes.

> Is there a better way of doing this?

Probably. Have you thought about pointers and named structures?
That would be my first thought. Then you wouldn't have to decide
ahead of time how many names and addresses you would have to have
for each state location. You could have a field that is a pointer
to a variable-length array of structures.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Progamming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Does IDL 5.2 require Solaris 2.6?
Next Topic: IDL: Structure of Structures?

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

Current Time: Wed Oct 08 19:23:59 PDT 2025

Total time taken to generate the page: 0.15406 seconds