interrupting a repeat loop

Phil Davis revdev at pdslabs.net
Tue Dec 15 12:20:53 EST 2009


Another way to check for any key being down is:

command runTheLoop
    repeat forever
       if the keysDown <> empty then exit repeat
       -- do what you want
    end repeat
end runTheLoop

HTH -
Phil Davis



On 12/15/09 7:59 AM, Robert Brenstein wrote:
> On 15.12.2009 at 16:01 Uhr +0100 Jacques Hausser apparently wrote:
>> Hi Tim
>>
>> it depends of the kind of loop you are using. Several possibilities 
>> For example in a card script:
>>
>> local stoploop
>>
>> command runTheLoop
>>    repeat forever
>>       if stoploop = "S" then exit repeat
>>       -- do what you want
>>       wait 10 milliseconds with message
>>    end repeat
>> end runTheLoop
>>
>> on keyDown thekey
>>     put thekey into stoploop
>> end keydown
>>
>> The "wait x milliseconds with message" is the important trick here.
>>
>> Jacques
>>
>
>
> If it is not relevant which key is being pressed, then a tad simpler 
> variation is
>
> command runTheLoop
>    repeat forever
>       if the shiftkey is down then exit repeat
>       -- do what you want
>    end repeat
> end runTheLoop
>
> It could also be altKey/optionKey or controlKey/commandKey instead of 
> shiftkey.
>
> Robert

-- 
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net




More information about the Use-livecode mailing list