Page 1 of 1

Cannot stop a running process with a Stop button.

Posted: Wed Feb 03, 2010 3:47 pm
by alex298
Hi,

I have a small program. There is a button used to run something for quite a long time, about 15 minutes. There is a stop button that can used to stop the process if the user want to quit it. Here's the scripts of the two buttons:

Run Button's script
global check_server
on mouseUp
put true into check_server
GetServer
end mouseUp

on GetServer
Repeat with i = 1 to the num of lines of field "testing"
if check_server = false then exit GetServer
//...... do something here
wait 2 seconds
end repeat
end GetServer
Stop Button's script
global check_server
on mouseUp
repeat for each line whichMessage in the pendingMessages
if "GetServer" is in whichMessage then cancel item 1 of whichMessage
end repeat
put false into check_server
## notify user
put "Shutting down......." into fld "Alert"
end mouseUp
However when the Run button is pressed, the stop button seems to be "inactivated". When try to press the stop button, nothing happens until the running is finished (i.e. 15 minutes later).

Please help to fix the problem.

P.S. This is really strange that I used this method about two years ago and it worked!

Thanks and best regards

Re: Cannot stop a running process with a Stop button.

Posted: Wed Feb 03, 2010 5:00 pm
by Janschenkel
Change the 'wait 2 seconds' in your long running script to 'wait 2 seconds with messages' - this allows other controls to react to events.

HTH,

Jan Schenkel.

Re: Cannot stop a running process with a Stop button.

Posted: Thu Feb 04, 2010 2:56 pm
by alex298
Dear Jan,

Thannnnnnnnnnks! It works perfectly!

You are really very helpful.

Best regards