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 #38991 is a reply to message #19984] Thu, 15 April 2004 10:39 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Craig Markwardt wrote:

>
> Kenneth Bowman <k-bowman@null.tamu.edu> writes:
>
>> In article <a6ebc8fb.0404150705.7a9f883b@posting.google.com>,
>> dsteinberg@whrc.org (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
>>
>> See "Arrays of Structures" in Chapter 7 of "Building IDL Applications.
>> You can use REPLICATE to create the array of structures.
>
> That was my first reaction too, but if you read the OP carefully, he
> discusses "multiple *different* anonymous structures," (emph added).
>
> It is impossible to make an array of dissimilar structures in IDL. The
> poster really must use an array of pointers, and then each pointer can
> point to a different structure.
>
> Craig
>


I can show a trick with two of our routines to get arrayed pointers on the
tags and then we can do a reformation of the structure if this is
necessary.

In difference to your answer Craig the pointers are on the tags not several
structures are as pointer arrayed. One tag could be changed without
redefinition of the whole structure. But I am not sure if this is wanted at
the moment. So this is only an addition to your answer.



IDL> names=['file','img']
IDL>
ptr=[ptr_new([ptr_new('file1'),ptr_new('file2')]),ptr_new([p tr_new(bytarr(10,5)),ptr_new(bytarr(10,10))])]

IDL> s=names_and_ptrs2struct(names,ptr)
IDL> help,s,/str
** Structure <81de694>, 2 tags, length=16, data length=16, refs=1:
FILE POINTER Array[2]
IMG POINTER Array[2]

IDL> help,*s.img[0]
<PtrHeapVar21> BYTE = Array[10, 5]

IDL> help,*s.img[1]
<PtrHeapVar22> BYTE = Array[10, 10]


IDL> x=reform_struct(s,2,/struct_arr)
% Compiled module: REFORM_STRUCT.
IDL> help,x,/str
** Structure <81de814>, 2 tags, length=8, data length=8, refs=1:
FILE POINTER <PtrHeapVar18>
IMG POINTER <PtrHeapVar21>
IDL> help,x
X STRUCT = -> <Anonymous> Array[2]



The routines are in the library at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html

regards
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: Fri Oct 17 21:31:45 PDT 2025

Total time taken to generate the page: 0.08297 seconds