Re: delete a tagname from a structure? [message #9702] |
Sat, 09 August 1997 00:00 |
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  |
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
|
|
|