Re: How to kill a procedure? [message #13688] |
Mon, 07 December 1998 00:00 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Med Bennett wrote:
> I am wondering how to kill an errant IDL procedure in Windows 95 without
> killing the whole application and starting over. I sometimes make a
> programming error which causes a procedure to go into an infinite loop.
> It seems like I used to be able to hit ctrl-C in older versions of IDL,
> at least in procedures that had some sort of print statement in them, to
> exit out of a procedure. But recently when this has happened, nothing
> seems to work and I have to hit ctrl-alt-delete and kill IDL entirely,
> which is very annoying, especially if I have unsaved variables. Any
> suggestions would be greatly appreciated!
>
> Thanks in advance,
>
> Med Bennett
> mbennett @ indra.com
> IDL 5.0.2
> Windows95
> Pentium-133, 48 MB RAM
My first Idea was to start first a widget in timer mode and if key pressed
to send a breakpoint to the calling routine.
Unfortunately I don't know why the eventhandler isn't accessed. Therefore I
added widget_event.
May be David F. is able to solve this in a better way ?!
Normally if you use wait, xx you are able to break with CTRL BREAK a running
process.
My solution is at the moment.
PRO test
result=x_breaker()
FOR i=0l,100000l DO BEGIN
res=WIDGET_EVENT(result.base,/nowait)
WAIT,0.01
PRINT,i
ENDFOR
END
result=x_breaker() starts a mini widget with the break button
You have to set a wait in your code
res=WIDGET_EVENT(result.base,/nowait) will switch to the widget.
If Break is pressed a breakpoint will be send to the routine and it will
stop.
; Copyright (c) 1998, Forschungszentrum Juelich GmbH ICG-1
; All rights reserved.
; Unauthorized reproduction prohibited.
; This software may be used, copied, or redistributed as long as it is not
; sold and this copyright notice is reproduced on each copy made. This
; routine is provided as is without any express or implied warranties
; whatsoever.
;
;+
; NAME:
; x_breaker
;
; PURPOSE:
; This widget procedure is used to break a routine by sending a breakpoint
;
; CATEGORY:
; PROG_TOOLS/WIDGETS
;
; CALLING SEQUENCE:
; x_breaker
;
;
; EXAMPLE:
; PRO test
; result=x_breaker()
; FOR i=0l,100000l DO BEGIN
; res=WIDGET_EVENT(result.base,/nowait)
; WAIT,0.01
; PRINT,i
; ENDFOR
; END
;
;
; MODIFICATION HISTORY:
; Written by: R.Bauer (ICG-1), 1998-Dec-07
;-
PRO x_breaker_event,ev
WIDGET_CONTROL, ev.id, get_uval=cmd
WIDGET_CONTROL, ev.top, get_uval=map
WIDGET_CONTROL, map.base, get_uval=struct
IF SIZE(cmd,/type) NE 8 THEN BEGIN
CASE cmd[0] OF
'BREAK': BEGIN
HELP,call=call
line=LONG((STR_SEP((STR_SEP(call[1],'('))[1],')'))[0])
file=(STR_SEP((STR_SEP(call[1],'<'))[1],'('))[0]
BREAKPOINT,file,line
END
ELSE:
ENDCASE
ENDIF
END
FUNCTION x_breaker
base=WIDGET_BASE(col=3,title='Break a running Script')
id_break=WIDGET_BUTTON(base,Value='BREAK',UVALUE='BREAK',/AL IGN_CENTER,event_pro='x_breaker_event')
result={base:base}
WIDGET_CONTROL,base,set_uval= result,/realize , /XMANAGER_ACTIVE_COMMAND
RETURN,result
END
Regards
R.Bauer
|
|
|