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

Home » Public Forums » archive » delete a tagname from a structure?
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: delete a tagname from a structure? [message #86011 is a reply to message #86002] Tue, 24 September 2013 01:44 Go to previous messageGo to previous message
Fabzi is currently offline  Fabzi
Messages: 305
Registered: July 2010
Senior Member
Hi

On 09/23/2013 11:55 PM, spluque@gmail.com wrote:
> Searching for a way to remove a field from a structure,

I found this in my lib, I don't remember who wrote the code in the first
place but it's not that complex:

;+
; :Description:
; Removes a tag from a structure.
;
; :Params:
; struct: in, required
; the structure
; tagname: in, required, type=string
; the tag name
;
;-
pro w_remove_tag, struct, tagname

; Set Up environnement
COMPILE_OPT idl2

if n_params() ne 2 then MESSAGE, 'N_PARAMS=2'

searchtag=strupcase(tagname)
tagnames=tag_names(struct)
a=[-1]
if n_elements(tagname) eq 1 then a=[a,where(tagnames $
ne searchtag)] else for i=0,n_elements(tagnames)-1 do $
if (where(searchtag eq tagnames[i]))[0] eq -1 then a=[a,i]
if n_elements(a) eq 1 then return
if a[1] eq -1 then return
newstruct=create_struct(tagnames[a[1]],struct.(a[1]))
if n_elements(a) gt 2 then for i=2,n_elements(a)-1 $
do newstruct=create_struct(newstruct,tagnames[a[i]],struct.(a[i ]))
struct=newstruct

end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: A newbie question regarding 3D plotting
Next Topic: Does the IDLDE regularly hang for anyone else?

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

Current Time: Sat Oct 11 09:45:59 PDT 2025

Total time taken to generate the page: 0.08835 seconds