For Programmers: Free Programming Magazines  


Home > Archive > Clarion > April 2007 > Re: Cancelling a Loop help`









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Cancelling a Loop help`
pblais@odstrategies.org

2007-04-06, 6:55 pm

You need a window to hold the button else you need the Window so you
can have a timer event and trap a Notify sent from the button some
place else. The Timer event is what you need and you can't have it in
source procedure. Moving the cancel button to the Window makes it
easier. You can then write code to perform a certain number of
iterations on each timer event. Set up some state variables so you can
act based on the state. You can trap the Cancel accepted event when
you process the Timer event.

I use a routine that is called from the timer event. It has a CASE
statement on the current state. Like Init, Error, Done, Cancelled.
Processing is done in a tight loop for a fixed number of iterations or
less if it completes and resets the state to done or error. After the
number of loops is executed you exit the routine and let it get called
again on the next timer event. This will let other threads run and the
user can hit the cancel button.

In your current code you'll never know when any event is posted. You
can't check the events inside your loop. A Window on a timer of 1
works quite well. You can save the CLOCK() time at the start and use
that if you want to say time out in 10 minutes.

On 6 Apr 2007 11:36:56 -0400, "Dan Scott" <PingMe@ng.com> wrote:

>This is in a source procedure

---------------------------------------
Paul Blais - Hayes, Virginia
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com