Exit Repeat

Geoff Canyon gcanyon at inspiredlogic.com
Sun Mar 19 17:24:58 EST 2006


On Mar 19, 2006, at 12:04 PM, Mark Smith wrote:

> Andre, the trouble is that in the case of interrupting a repeat  
> loop, you can't test for whether the escape key is down like you  
> can with control/option/command.
>
> So use control/option/command, of course :)
> But the escape key would be more natural...

This works:

local sGetOut

on mouseUp
   put empty
   put false into sGetOut
   repeat 20000
     wait 0 ticks with messages
     if sGetOut then exit to top
   end repeat
   put "completed"
end mouseUp

on escapeKey
   put true into sGetOut
end escapeKey

Note that the escapeKey message is delivered to the focused control,  
so you can't put it in a button and expect it to work reliably. Put  
the above in the card script, then click anywhere in the card. Some  
time later "completed" will show in the message box. Then click the  
card again and then press the escape key. You won't get the  
"completed" text.

gc



More information about the use-livecode mailing list