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

Home » Public Forums » archive » Re: Deleting Variables
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: Deleting Variables [message #11614] Fri, 24 April 1998 00:00
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
lundblad@ugastro.berkeley.edu (Nathan Lundblad) writes:


> How does one delete variable in IDL?

> I know _delvar_, but that only works on the
> main level of the program, and only one on
> variable. I want to purge everything.

> Also, how would one delete a common block?

I don't think one can delete an entire common block. However, here is simple
routine that can delete any variable, even those in subroutines or common
blocks. Actually, it sets them to undefined, which is almost the same thing.

Bill Thompson

============================================================ ===================
pro delvarx, p0,p1,p2,p3,p4,p5,p6,p7,p8,p9
;
;+
;
; Project: SSW
;
; Name: delvarx
;
; Purpose: delete variables for memory management (can call from routines)
;
; Input Parameters:
; p0,p1...p9 - variables to delete
;
; Calling Sequence:
; delvarx, a [,b,c,d,e,f,g,h,i,j] ;deletes named variables
; ;like idl delvar, but may be used
; ;from any calling level
;
; History:
; S.L.Freeland 25-feb-1993 ; Written
; slf, 8-mar-1993 ; bug fix
; slf, 25-mar-1993 ; made it work for non-scalers!
; slf, 15-jan-1997 ; Documentataion->SSW
;
;
; Method: uses execute and temporary function
;-
for i=0, n_params()-1 do begin ;for each parameter
param=strcompress("p" + string(i),/remove)
; only delete if defined on inpu (avoids error message)
exestat = execute("defined=n_elements(" + param + ")" )
if defined gt 0 then begin
exestat = execute(param + "=0")
exestat = execute("dvar=temporary(" + param + ")" )
endif
endfor
return
end
Re: Deleting Variables [message #11617 is a reply to message #11614] Fri, 24 April 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Nathan Lundblad (lundblad@ugastro.berkeley.edu) writes:

> How does one delete variable in IDL?
>
> I know _delvar_, but that only works on the
> main level of the program, and only one on
> variable. I want to purge everything.

If you wanted to get rid of all the IDL variables that
exist at the main IDL level, you could write a program
like this:

PRO Purge
END

When you want to get rid of all main-level variables,
you would type:

IDL> .RNew Purge

If you want to get rid of a single variable within an
IDL program module (i.e., NOT at the main level), you
can download the program UNDEFINE from my web page:

Undefine, variable

If you want to get rid of all the pointers and objects
you have accidentally deleted references to, you can
type this:

IDL> Heap_GC

If you just want to get rid of *everything* (including
common blocks, which can be deleted in no other way),
most of the experts use this trick:

IDL> Exit

:-)

Cheers,

David

-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Satellite Image Data-Map Projection Question
Next Topic: Re: How to skip some bytes?

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

Current Time: Fri Oct 10 03:15:31 PDT 2025

Total time taken to generate the page: 0.47781 seconds