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

Home » Public Forums » archive » Re: Append tag to an array 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: Append tag to an array of structures [message #34535] Wed, 26 March 2003 16:29
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 26 Mar 2003 14:01:40 -0700, Wayne Landsman wrote:

> JD Smith wrote:
>> Anyone have a clever method for appending a tag to an array of
>> structures? For a single structure, it's easy:
>>
>> new_struct=create_struct(struct,'NewTag',1.21)
>
> Well, I would hardly call it clever or efficient but one way is to
> create a structure of the right size and then use the copy_struct.pro
> procedure in
> http://idlastro.gsfc.nasa.gov/ftp/pro/structure/copy_struct. pro to copy
> all the previous tag information
>
> n = N_elements(struct)
> new_struct = replicate(create_struct(struct[0],'NewTag',1.21),N)
> copy_struct, struct, new_struct
>
> --Wayne Landsman landsman@mpb.gsfc.nasa.gov


Thanks Wayne. I came up with something similar using the builtin
"struct_assign,struct,new_struct,/NOZERO". I was hoping not to use
replicate though.

JD
Re: Append tag to an array of structures [message #34539 is a reply to message #34535] Wed, 26 March 2003 13:01 Go to previous message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
JD Smith wrote:
> Anyone have a clever method for appending a tag to an array of
> structures? For a single structure, it's easy:
>
> new_struct=create_struct(struct,'NewTag',1.21)

Well, I would hardly call it clever or efficient but one way is to
create a structure of the right size and then use the copy_struct.pro
procedure in http://idlastro.gsfc.nasa.gov/ftp/pro/structure/copy_struct. pro
to copy all the previous tag information

n = N_elements(struct)
new_struct = replicate(create_struct(struct[0],'NewTag',1.21),N)
copy_struct, struct, new_struct

--Wayne Landsman landsman@mpb.gsfc.nasa.gov
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: console output under Windows
Next Topic: License increases?

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

Current Time: Wed Oct 08 13:39:02 PDT 2025

Total time taken to generate the page: 0.00639 seconds