Deleting a System Variable

QUESTION: I realize this question probably doesn't make much sense, but is it possible to delete or undefine an IDL system variable that you have created yourself? DelVar completely chokes on a system variable, and Undefine doesn't cause an error but doesn't appear to do anything either. Is there something I am missing?

ANSWER: Not really. It is mostly impossible to delete a system variable once you have created it with DefSysV. But, Ben Tupper points out that there is one small loophole in this logic. Namely, if you make your system variable a pointer, it is possible to delete it. Or at least it is possible to make it act as if it were deleted.

Consider the following example.

   IDL> DefSysV, '!Tester', Ptr_New(5)
   IDL> Help, !Tester
   <Expression>    POINTER   = <PtrHeapVar1>
   
   IDL> Help, /Heap
   Heap Variables:
       # Pointer: 1
       # Object : 0
   <PtrHeapVar1>   LONG      =            5
   
   IDL> Help, *!Tester
   <PtrHeapVar1>   LONG      =            5

   IDL> Ptr_Free, !Tester
   IDL> Help, *!Tester
   % Invalid pointer: <POINTER  (<PtrHeapVar1>)>.
   % Execution halted at: $MAIN$       
   
   IDL> Help, /Heap
   Heap Variables:
       # Pointer: 0
       # Object : 0

The system variable !Tester has apparently been deleted!

Version of IDL used to prepare this article: IDL 7.1.

Google
 
Web Coyote's Guide to IDL Programming