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

Home » Public Forums » archive » Re: question on destroying objarr's
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: question on destroying objarr's [message #62060] Tue, 19 August 2008 13:07
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jean H. writes:

> loop through them...
> for i=0,2 do obj_destroy, myObjArr[i]

Oh, for goodness sake. Totally unnecessary!

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: question on destroying objarr's [message #62062 is a reply to message #62060] Tue, 19 August 2008 12:12 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
cgoethel@igpp.ucla.edu wrote:
> Hello,
>
> Does anyone have a simple example of how to create, populate, and
> destroy an objarr? I can create and populate (in a clumsy way) but
> then I am cannot get rid of it using OBJ_DESTROY.
>
> Thanks! Cindy
>
> EX:
>
> myObjArr=OBJARR(3)
> myObjArr[0]=someObj
> OBJ_DESTROY, myObjArr
>
> help, myObjArr
> MYOBJARR OBJREF = Array[3] (it's still there - why?)

loop through them...
for i=0,2 do obj_destroy, myObjArr[i]

Jean
Re: question on destroying objarr's [message #62063 is a reply to message #62062] Tue, 19 August 2008 12:02 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Well, it's still there in the sense that variable myObjArr
> is still listed as having been previously defined as
> *something* in the IDL session. But all the objects in
> that object array are null objects. You can't use them
> for anything. They don't point to anything. They are not
> taking up any space on the heap. Etc.
>
> In other words, you are in great shape! :-)

Here is another way of looking at this:

IDL> myObjArr=OBJARR(3)
IDL> myObjArr[0]=Obj_New('idlanroi')
IDL> Help, /HEAP
Heap Variables:
# Pointer: 0
# Object : 1

<ObjHeapVar21> STRUCT = -> IDLANROI Array[1]

IDL> OBJ_DESTROY, myObjArr
IDL> Help, /HEAP
Heap Variables:
# Pointer: 0
# Object : 0

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: question on destroying objarr's [message #62064 is a reply to message #62063] Tue, 19 August 2008 11:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
cgoethel@igpp.ucla.edu writes:

> Does anyone have a simple example of how to create, populate, and
> destroy an objarr? I can create and populate (in a clumsy way) but
> then I am cannot get rid of it using OBJ_DESTROY.
>
> Thanks! Cindy
>
> EX:
>
> myObjArr=OBJARR(3)
> myObjArr[0]=someObj
> OBJ_DESTROY, myObjArr
>
> help, myObjArr
> MYOBJARR OBJREF = Array[3] (it's still there - why?)

Well, it's still there in the sense that variable myObjArr
is still listed as having been previously defined as
*something* in the IDL session. But all the objects in
that object array are null objects. You can't use them
for anything. They don't point to anything. They are not
taking up any space on the heap. Etc.

In other words, you are in great shape! :-)

If you want to get rid of it entirely, you will have to
do something like this:

IDL> myObjArr=OBJARR(3)
IDL> myObjArr[0]=Obj_New('idlanroi')
IDL> OBJ_DESTROY, myObjArr
IDL> Undefine, myObjArr
IDL> Help, myObjArr
MYOBJARR UNDEFINED = <Undefined>

You can find UNDEFINE here:

http://www.dfanning.com/programs/undefine.pro

Just don't undefine before you destroy!!!

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 3D graphing
Next Topic: Re: Today's IDL Lesson

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

Current Time: Wed Oct 08 19:05:42 PDT 2025

Total time taken to generate the page: 0.01044 seconds