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

Home » Public Forums » archive » Call object cleanup method when IDL exits
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: Call object cleanup method when IDL exits [message #85629 is a reply to message #85623] Thu, 22 August 2013 10:29 Go to previous messageGo to previous message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
Hi Moritz,

Thanks for this very helpful response. The only tweak I've added is to test
the strings returned by HELP to make sure that they're valid variable names.
My next step may be to emulate the IDL_STARTUP mechanism by testing
for an IDL_SHUTDOWN environment variable and executing any commands
in the named file before calling exit.

pro my_exit

help, level=-99, output=o
variables = strsplit(strjoin(o,' '),' ',/extract)
foreach var, variables do begin
if idl_validname(var) then begin
tmp = temporary(scope_varfetch(var, level=-1, /enter))
tmp = 42 ; the answer to the question
endif
endforeach
exit

end

All the best,

David


On Thursday, August 22, 2013 10:31:59 AM UTC-4, Moritz Fischer wrote:
> Hi David,
>
>
>
> sorry, I didn't mean to pm you.
>
> However, I just figured out you can do this:
>
>
>
> PRO my_exit
>
> help, LEVEL=-1, OUTPUT=o
>
> funny_array = strsplit( strjoin( o, ' '),' ', /EXTRACT)
>
> foreach var, funny_array do $
>
> tmp = temporary( scope_varfetch(var, LEVEL=-1, /ENTER) )
>
> tmp=42
>
> exit
>
> END
>
>
>
> Neverthe less: Let me know if you find something more elegant!
>
>
>
> cheers
>
>
>
> Am 22.08.2013 15:04, schrieb David Grier:
>
>> Dear Folks,
>
>>
>
>> I want to ensure that my object's cleanup method is called when IDL exits.
>
>> What's the right way to do this?
>
>>
>
>> The issue is that my object spawns a background process that it subsequently
>
>> kills when the object is cleaned up. It appears that IDL does not automatically
>
>> call objects' cleanup methods when it shuts down normally.
>
>> Consequently, the background process can be left running.
>
>>
>
>> This isn't a problem for well-written programs that explicitly call obj_destroy.
>
>> It arises all the time during interactive sessions, however.
>
>>
>
>> Is there a switch that tells IDL to be extra fastidious about cleaning up objects?
>
>> Perhaps an equivalent to IDL_STARTUP that works on shutdown? Or is there some
>
>> other technique to ensure that every object on the heap is cleaned up before
>
>> IDL shuts down?
>
>>
>
>> Many thanks,
>
>>
>
>> David
>
>>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Navigating AVIRIS Images
Next Topic: avoiding "floating illegal operand" errors with /nan keyword in mean

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

Current Time: Wed Oct 08 19:26:11 PDT 2025

Total time taken to generate the page: 0.00422 seconds