Interrupting a loop

Michael J. Lew michaell at unimelb.edu.au
Tue Feb 17 21:30:21 EST 2004


This is something that I do quite often. Messages are generally a 
better idea than a repeat loop because they allow other handlers to 
be run at the same time so your user can do other stuff. Here is a 
skeletal script that should get you going. You will need a button to 
contain the first script and another called "Pause" with the second 
script. (I used a custom property to control the increment just to 
show where another control might alter the process.)

First button (give it a custom property called cIncrement and set it 
to a number):
on mouseUp
   put 0
   addSome
end mouseUp

on addsome
   add the cIncrement of me to msg
   if not the hilite of btn "pause" then send addSome to me in 10 milliseconds
end addsome

Pause button (I used a checkbox):
on mouseUp
   if not the hilite of me then send "addsome" to btn 1
end mouseUp

Hope that helps.

-- 
Michael J. Lew

Senior Lecturer
Department of Pharmacology
The University of Melbourne
Parkville 3010
Victoria
Australia

Phone +613 8344 8304

**
New email address: michaell at unimelb.edu.au
**


More information about the use-livecode mailing list