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

Home » Public Forums » archive » Array of structures.
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: Array of Structures [message #38996 is a reply to message #19984] Thu, 15 April 2004 08:51 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Dan Steinberg wrote:

> I am wondering if it is possible to create an array of structures. I
> want to read multiple different anonymous structures into a single
> variable so I can reference each structure using the variable name and
> the array index. Is this possible?
>
> -Dan

Yes

but there is a small risk that it only works with named structures.
It is only guaranted that it works with named structures.

First way

IDL> a=create_struct(name='tst','file','','bmp',bytarr(10,20))
IDL> help,a,/str
** Structure TST, 2 tags, length=212, data length=212:
FILE STRING ''
BMP BYTE Array[10, 20]

IDL> s=replicate(a,10)
IDL> help,s
S STRUCT = -> TST Array[10]


second way is to use the structure name

IDL> b=[a,{tst}]
IDL> help,b
B STRUCT = -> TST Array[2]

third way

IDL> c=[a,a]
IDL> help,c,/str
IDL> help,c
C STRUCT = -> TST Array[2]


This was the creation.

Accessing:


IDL> help,c[0].(0)
<Expression> STRING = ''

IDL> help,c[0].(1)
<Expression> BYTE = Array[10, 20]

IDL> help,c[0].(1)[0,*]
<Expression> BYTE = Array[1, 20]


IDL> help,c[0].bmp[0,*]
<Expression> BYTE = Array[1, 20]



If the sizes or type of your variables are different I suggest to use
pointer.

Cheers

Reimar
--
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Array of Structures
Next Topic: Can IDL look after graphics in C++ code?

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

Current Time: Mon Oct 27 12:43:49 PDT 2025

Total time taken to generate the page: 0.96242 seconds