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

Home » Public Forums » archive » Re: How to add a new tag to N 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: How to add a new tag to N structures [message #69989 is a reply to message #69972] Thu, 04 March 2010 04:00 Go to previous messageGo to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
nata schrieb:
> Hi guys,
>
> I want to add a new TAG to an array of structures. I don't know how to
> do that efficiently.
> For example, this is my array:
>
> str={a: 0l, b: ''}
> str_arr=REPLICATE(str,10)
>
> And I can't do things like this:
>
> FOR i=0, 9 DO str_arr[i]=CREATE_STRUCT(str_arr[i],'C',0l)
> or
> str_arr=CREATE_STRUCT(str_arr[i],'C',0l)
>
> This is just an example, my real structs contain a lot of fields.
>
> For some reasons I can define the C tag before so I have to add to
> each struct later. There is a way to do that without creating the new
> struct array and copying each field separately ?
> Thanks,
> nata


well you can reform your array of structures to an structure with
arrays. then you can add your new tag to that structure. Afterwards
reform it back to your array of structures

e.g.
str={a: 0l, b: ''}
str_arr=REPLICATE(str,10)

ref_str = reform_struct(str_arr, /tag_array, 10)
ref_str = create_struct(ref_str, 'c' ,make_array(10))
help, ref_str, /str
** Structure <2800d48>, 3 tags, length=240, data length=240, refs=1:
A LONG Array[10]
B STRING Array[10]
C FLOAT Array[10]

str = reform_struct(str_arr, /struct_array, 10)
help, str
STR STRUCT = -> <Anonymous> Array[10]

You get reform_struct from
http://www.fz-juelich.de/icg/icg-1/idl_icglib/idl_source/idl _html/dbase/reform_struct_dbase.pro.html

cheers
Reimar
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MOD09 Data in ENVI
Next Topic: Re: MOD09 Data in ENVI

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

Current Time: Fri Oct 10 07:51:17 PDT 2025

Total time taken to generate the page: 2.15856 seconds