interrupting a repeat loop

zryip theSlug zryip.theslug at gmail.com
Tue Dec 15 15:04:13 EST 2009


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 Tim,

Maybe you could use the keysDown function.
This RR function returns the ascii form of the keys pressed while a handler
is being executed.

For example this mouseUp handler add 1 to the fld msg until the key "s" is
pressed :

*on* mouseUp

   *put* 0 into fld "Msg"

   *repeat* until charToNum("s") is in 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


Hope this helps.

- Zryip TheSlug - wish you the best 8)



More information about the use-livecode mailing list