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

Home » Public Forums » archive » Re: Renaming tags in an 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: Renaming tags in an array of structures [message #72548 is a reply to message #72542] Thu, 16 September 2010 12:05 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Sep 16, 3:28 pm, Michael Williams <mjwilli...@gmail.com> wrote:
> I have an array of structures:
>
> IDL> x = {a: 1, b:2, c: indgen(5)}
> IDL> xx = replicate(x, 10)
>
> In this case, I want to rename the 'b' tag to 'foo' and the 'c' tag to
> bar. But I want a function that works for arbitrary tag names. I have
> readhttp://www.dfanning.com/code_tips/addfield.html, which describes
> how to add a field to an array of structures using struct_assign. So
> far I have the following function, which seems like it's headed in the
> right direction: it will add the foo and bar tags. But (i) it only
> works if you're renaming exactly two tags because of the create_struct
> call (ii) it doesn't copy the data in the old tags to the new tags and
> (iii) it doesn't delete the old tags, which is necessary for true
> "replacement".
>
> Can anyone see how to fix these problems so that the function works
> for arbitrarily many tag names, copies the data (ideally without using
> execute statements, which is the only way I can think of doing it),
> and the old fields are deleted? Or is there another solution
> altogether?

Any reason not to do it with hashes and avoid all those troubles?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: color tiffs
Next Topic: Re: IDL 8.0; difficulties with "New Graphics"

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

Current Time: Sat Oct 11 13:13:45 PDT 2025

Total time taken to generate the page: 1.12083 seconds