Cancel a repeat with a button

Scott Rossi scott at tactilemedia.com
Thu May 14 00:31:53 EDT 2009


Recently, Stephen Cox wrote:

> Why not? You checking a global variable. He said it would take a while to
> complete. And I'm assuming he's running the loop in the background.

Revolution doesn't process events asynchronously.  During a straightforward
repeat loop, nothing gets processed or sent while the loop executes, so a
mouseclick would never be detected.  You need to make allowances in the
script for this to happen.  There are a few ways this could be done:

You could poll the mouse: "if the mouse is down...".  This practice has been
discouraged in the past because it was deemed in efficient and somewhat
unreliable, but with recent versions of Rev and newer machines, it can work.

You could add a "wait" command: "wait 10 millisecs with messages".  The
"with messages" portion allows messages and events to be processed in
between the loops.  Here's where a global, custom property, or other
variable could be checked.

Another way entirely to run a loop is using "send in...":

on myProcessingLoop
  doMyStuff
  send "myProcessingLoop" to me in 10 millisecs
end myProcessingLoop

This method inherently allows for other events/messages to be processed.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design





More information about the use-livecode mailing list