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

Home » Public Forums » archive » Re: delete a tagname from a structure?
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: delete a tagname from a structure? [message #9702] Sat, 09 August 1997 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
R. Bauer writes:

> I like to remove a tagname from a structure.
>
> Any ideas?

If it is an anonymous structure, you can just
redefine the structure without the tag. For example,
like this:

struct = {a:FltArr(10), b:FltArr(10), c:FltArr(10)}

To remove tag b:

struct = {a:struct.a, c:struct.c}

If you have named structures, I am afraid you are out
of luck.

Cheers,

David

----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
Customizable IDL Programming Courses
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com
Re: delete a tagname from a structure? [message #9705 is a reply to message #9702] Fri, 08 August 1997 00:00 Go to previous message
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
R. Bauer wrote:
>
> Hi,
>
> I like to remove a tagname from a structure.
>
> Any ideas?
>
> --
> R.Bauer
>
> Institut fuer Stratosphaerische Chemie (ICG-1)
> Forschungszentrum Juelich
> email: R.Bauer@fz-juelich.de


st={tag1:1,tag2:2,tag3:3,tag4:4} ; a structure
tags=tag_names(st)
list=[0,1,3] ;; list of which elements to keep
st=create_struct(tags[list],st.(list[0]),st.(list[1]),st.(li st[2]))


If you have a named struct, you can use
name=tag_names(st,/STUCTURE_NAME) and create_struct(name=name,...)

For a totally general method which doesn't preassume the number of tags
to keep, you'd have to build an 'execute' statement.

E.g.

n=strtrim(n_elements(list),2)
exc='st=create_struct(tags[list],'+string(FORMAT='('+n+'("st.(list[ ",I0,"])",:,","))',indgen(n_elements(list)))+')'
out=execute(exc)

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Least Square
Next Topic: differnces in structures for idl5

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

Current Time: Wed Oct 08 13:34:31 PDT 2025

Total time taken to generate the page: 0.00481 seconds