interrupting a repeat loop

zryip theSlug zryip.theslug at gmail.com
Tue Dec 15 17:38:28 EST 2009


2009/12/15 zryip theSlug <zryip.theslug at gmail.com>

>
>
> 2009/12/15 Tim Selander <selander at tkf.att.ne.jp>
>
> Is there any way in RR to check for user input during a repeat loop? I'd
>> like a loop to continue until the user types a certain key -- at which point
>> the script would exit the handler.
>>
>> Tim Selander
>> Tokyo, Japan
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
Hi again,

In my previous solution I proposed this loop :

*repeat* until charToNum("s") is in the keysDown

However, the use of "is in" to test the presence of a number in a list is
risky. Because for example, "122" may be in "1222,256"

So to prevent bugs prefers this handler to my previous solution :

 *on* mouseUp

   *put* 0 into fld "Msg"

   *repeat* until charToNum("s") is among the items of the keysDown

      *-- the charToNum function is necessary to compare the key with the
content returned by the keysDown function. The keysDown function returns a
list of keys in ascii form separated by commas.*

      *add* 1 to fld "Msg"

      *wait* 30 ticks

   *end* *repeat*

*end* mouseUp


- Zryip TheSlug - wish you the best ! 8)

>



More information about the use-livecode mailing list