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

Home » Public Forums » archive » Re: [Q] removing undefined variables automatically/rename
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: [Q] removing undefined variables automatically/rename [message #7385] Wed, 06 November 1996 00:00
Phil Williams is currently offline  Phil Williams
Messages: 78
Registered: April 1996
Member
Iarla Kilbane-Dawe wrote:
>
> Hello,
>
> does anybody know if there's a handy routine for deleting undefined
> variables in IDL? Occasionally lots of them are setup accidentally and
> it's annoying to have deleting individually. Does anyone have a
> suggestion for dealing with this?
>

The attached pro file should do the trick. However, it may not work
nicely w/ common blocks.

> Also, does anyone know if it's possible to rename a variable? If you have
> a large array is can be tricky doing
>
> a = temporary(b)
> delvar,b
>
> Any suggestions?
>
> Thanks,
>
> Iarla.
>
> --
> ____________________________________________________________ _________
>
> Iarla Kilbane-Dawe Email: iarla@atm.ch.cam.ac.uk
> European Ozone Research Phone: +44 (0)1223 311 772
> Coordinating Unit Fax: +44 (0)1223 311 750
> Cambridge University, UK.
> ____________________________________________________________ _________

--
/*********************************************************** ********/
Phil Williams, Ph.D.
Research Instructor
Children's Hospital Medical Center "One man gathers what
Imaging Research Center another man spills..."
3333 Burnet Ave. -The Grateful Dead
Cincinnati, OH 45229
email: williams@irc.chmcc.org
URL: http://scuttle.chmcc.org/~williams/
/*********************************************************** ********/

;+
; NAME: CLEAN.PRO
;
; PURPOSE: Delete all undefined variables
;
; CATEGORY: Utility Functions
;
; CALLING SEQUENCE: IDL> clean
;
; INPUTS: none
;
; OPTIONAL INPUTS: none
;
; KEYWORD PARAMETERS: none
;
; OUTPUTS: none
;
; OPTIONAL OUTPUTS: none
;
; COMMON BLOCKS: none
;
; SIDE EFFECTS: none
;
; RESTRICTIONS: Only works on variables in the Main program space.
; Most likely will crash w/ common blocks. Must be run
; as $MAIN$.
;
; PROCEDURE: Straigthforward
;
; MODIFICATION HISTORY:
; v1.0 written by Phil Williams 11/6/1996
; williams@irc.chmcc.org
;-

;--- Get the Help Data
HelpData = gethelp(/fullstring)

vars = ''
for i = 0,n_elements(HelpData)-1 do begin
;--- Find the undefined ones
pos = strpos(HelpData(i), 'UNDEFINED')

;--- if undefined add to the list
if pos ne -1 then begin
pos = strpos(HelpData(i), ' ')
vars = vars + strmid(HelpData(i),0,pos) + ', '
endif
endfor

;--- Chop off the last ,
vars = strmid(vars, 0, strlen(vars) - 2)

;--- Make the DELVAR command
cmd = 'DELVAR, ' + vars

;--- Execute it!
r = execute(cmd)


end
  • Attachment: clean.pro
    (Size: 1.10KB, Downloaded 76 times)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: gcc and idl
Next Topic: Re: Parameter passing in PV-Wave

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

Current Time: Wed Oct 08 17:37:32 PDT 2025

Total time taken to generate the page: 0.00543 seconds