Cannot stop a running process with a Stop button.

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

Cannot stop a running process with a Stop button.

Post by alex298 » Wed Feb 03, 2010 3:47 pm

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
Alex
Nice to meet all of you.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

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

Post by Janschenkel » Wed Feb 03, 2010 5:00 pm

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

alex298
Posts: 101
Joined: Mon May 01, 2006 1:17 pm

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

Post by alex298 » Thu Feb 04, 2010 2:56 pm

Dear Jan,

Thannnnnnnnnnks! It works perfectly!

You are really very helpful.

Best regards
Alex
Nice to meet all of you.

Post Reply