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

Home » Public Forums » archive » endless loops suck
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
endless loops suck [message #33853] Thu, 30 January 2003 18:54 Go to next message
Thomas Gutzler is currently offline  Thomas Gutzler
Messages: 44
Registered: November 2002
Member
Hey :)

Is there any way to stop this while debuging ?
I tried CTRL+C and CTRL+BREAK which sometimes helps but not in this case.

pro loop_it
a = 1
while (1) do a = a + 1
end

pro kill_idl
print, 'start'
; debugger is here and you pressed accidently 'F10'
=> loop_it
print, 'stop'
end

*loop*,
Tom
Re: endless loops suck [message #33886 is a reply to message #33853] Tue, 04 February 2003 17:21 Go to previous message
Thomas Gutzler is currently offline  Thomas Gutzler
Messages: 44
Registered: November 2002
Member
Timm Weitkamp wrote:
> Today at 09:57 +0800, Thomas Gutzler wrote:
>
>> How is this possible ?
>>
>> FOR i=0,4 DO PRINT, i, ' ', /NONEWLINE
>> ^^^^^^^^^^ this may be a problem
>> Result:
>> 0 1 2 3 4
>
>
> Use a format string (see also "Format codes" in the online help), like
> this:
>
> FOR i=0,4 DO PRINT, i, FORMAT='($,I1," ")'
> PRINT

doh!
I tried FOR i=0,4 DO PRINT, i, FORMAT='(5(I1," "))'

close :)

thx all for enlightenin me with all this inspiring stuff :)

Tom
Re: endless loops suck [message #33890 is a reply to message #33853] Tue, 04 February 2003 13:36 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield (m.hadfield@niwa.cri.nz) writes:

> In other words, as proposed by David, the begin and end do matter. I'm
> sorry for doubting you, David!

Really, Mark! You can take everything I say for the Gospel truth.
Just examine the record. ;-)

Cheers,

David

P.S. Let's just say that in baseball (which is more and
more resembling one of those Kiwi free-for-alls you
call rugby) having a .500 batting average is the epitome
of excellence.

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: endless loops suck [message #33891 is a reply to message #33853] Tue, 04 February 2003 13:12 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
"Altyntsev Dmitriy" <alt@iszf.irk.ru> wrote in message
news:6b9fda50.0302040226.319c7487@posting.google.com...
>
> [ Discussing on how to make IDL code interruptible under Windows ]
>
> Instead of "print", TMP = WIDGET_EVENT(/NOWAIT) can be used. It
> forces IDL to process Windows events including break events and
> events that were sent to IDL by other applications. It allows other
> applications continue to work and makes the work on Windows
> "smoother" while IDL is running.

Very nice! For many years now I have used a "yielder widget" for this
purpose (David's progress bar widget will also do) but I have always
wanted a more lightweight, less visually obtrusive method. I always
thought you needed to feed a valid widget ID to WIDGET_EVENT!

Just a couple of extra comments, based on experiments on my system
(IDL 5.6, Win 2000, Pentium 2 800 MHz)

This is interruptible

while 1 do begin & tmp = widget_event(/NOWAIT) & endwhile

but this is not (so don't try it at home)

while 1 do tmp = widget_event(/NOWAIT)

In other words, as proposed by David, the begin and end do matter. I'm
sorry for doubting you, David!

The overhead for calling WIDGET_EVENT is small, about 5.5 microseconds
(cf 39 nanoseconds per iteration for an empty for loop).


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: endless loops suck [message #33909 is a reply to message #33853] Tue, 04 February 2003 06:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Altyntsev Dmitriy (alt@iszf.irk.ru) writes:

> Print is very time consuming operation, so I usually use something
> like this:
> if i mod 1000 EQ 0 then print, i, N
>
> Instead of "print" TMP = WIDGET_EVENT(/NOWAIT) can be used. It forces
> IDL to
> process Windows events including break events and events that were
> sent to IDL by other applications. It allowes other applications
> continue to work and makes the work on Windows "smoother" while IDL is
> running.

This is interesting, and suggestive, too. I wonder
if the ability to break into WHILE loops was added
when management of widget programs was taken out of
XManager. Makes sense that you would have to check
back to the command line periodically to see if a
widget event was waiting to be processed. If so, this
would be the first ever evidence of a positive benefit
from allowing users access to the IDL command line
when widget programs were running. :-)

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: endless loops suck [message #33914 is a reply to message #33853] Tue, 04 February 2003 02:26 Go to previous message
alt is currently offline  alt
Messages: 28
Registered: August 2001
Junior Member
on my win98 !version = { x86 Win32 Windows 5.4 Sep 25 2000 32
64}
I have the next situation

while 1 do a = 0 ; can not be breaked

while 1 do begin ; can not be breaked
a = 0
endwhile

while 1 do begin ; can be breaked by
a = 0 ; 1. clicking on Break button (always works)
print, '' ; 2. pressing F9 with cursor on desired line
endwhile ; 3. pressing Cntl-Break (sometimes interrupts with
; very long delay or does not work at all)

Print is very time consuming operation, so I usually use something
like this:
if i mod 1000 EQ 0 then print, i, N

Instead of "print" TMP = WIDGET_EVENT(/NOWAIT) can be used. It forces
IDL to
process Windows events including break events and events that were
sent to IDL by other applications. It allowes other applications
continue to work and makes the work on Windows "smoother" while IDL is
running.

Altyntsev Dmitriy




Thomas Gutzler <tgutzler@ee.uwa.edu.au> wrote in message news:<3E39E56E.5050803@ee.uwa.edu.au>...
> Hey :)
>
> Is there any way to stop this while debuging ?
> I tried CTRL+C and CTRL+BREAK which sometimes helps but not in this case.
>
> pro loop_it
> a = 1
> while (1) do a = a + 1
> end
>
> pro kill_idl
> print, 'start'
> ; debugger is here and you pressed accidently 'F10'
> => loop_it
> print, 'stop'
> end
>
> *loop*,
> Tom
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: OPENW and environment variables in IDL 5.5
Next Topic: Re: Test if variable is a string

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

Current Time: Wed Oct 08 13:26:22 PDT 2025

Total time taken to generate the page: 0.00612 seconds