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 #9790 is a reply to message #9715] Thu, 21 August 1997 00:00 Go to previous messageGo to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
This is a multi-part message in MIME format.

--------------1BA853742701
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Some days ago, in an article I don't have here, R. Bauer asked for such
a routine. Now I needed something like this for myself and wrote this
small routine I've attached here. It replaces a tag from a structure by
another, and also allows its deletion. Seems to work, although I don't
guarantee for anything...


Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de

--------------1BA853742701
Content-Type: text/plain; charset=us-ascii; name="replace_tag.pro"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="replace_tag.pro"

;+
; NAME:
; REPLACE_TAG
;
; PURPOSE:
; Replaces a tag in a structure by another
;
; CALLING:
; replace_tag, struct, old_tag, new_tag, value
;
; INPUTS:
; struct - the structure to be changed
; old_tag - name of the tag to be changed
; new_tag - name of the new tag
; If set to '', old_tag is deleted from the structure
; value - value of the new tag
;
; RESTRICTIONS:
; Does not work with named structures
;
; MODIFICATION HISTORY:
; Alex Schuster, MPIfnF, 8/97 - Written
;-

pro replace_tag, struct, old_tag, new_tag, value

tags = tag_names( struct )

pos = (where( tags eq strupcase( old_tag ) ))(0)
if ( pos eq -1L ) then begin
print, 'Error: Tag ', old_tag, ' not in struct.'
return
endif

if ( ( pos eq 0 ) and ( new_tag ne '' ) ) then begin
new_struct = create_struct( new_tag, value )
endif else begin
new_struct = create_struct( tags(0), struct.(0) )
for i = 1, pos-1 do $
new_struct = create_struct( new_struct, tags(i), struct.(i) )
if ( new_tag ne '' ) then $
new_struct = create_struct( new_struct, new_tag, value )
endelse
for i = pos+1, n_elements( tags )-1 do $
new_struct = create_struct( new_struct, tags(i), struct.(i) )

struct = new_struct

end

--------------1BA853742701--
[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 21:12:19 PDT 2025

Total time taken to generate the page: 0.08086 seconds