simulate keystroke

Larry Watts lgwatts at adelphia.net
Mon Oct 27 00:05:54 EDT 2008


thanks Jacqueline,
this is similar to a timer we use in another app.  we can pause the timer by 
clicking on a different button.  so tomorrow, i'll have a go at implementing 
your code here in my new app.

Larry
P.S. Terry, I tried your idea exactly as you gave it. I put it in a test 
button, but Rev behaved very inconsistently with it.

----- Original Message ----- 
From: "J. Landman Gay" <jacque at hyperactivesw.com>
To: "How to use Revolution" <use-revolution at lists.runrev.com>
Sent: Sunday, October 26, 2008 7:11 PM
Subject: Re: simulate keystroke


> J. Landman Gay wrote:
>> Larry Watts wrote:
>>> hi Mark,
>>> What I'm really wondering how to do is this:
>>> I have a button script running with a lot of repeat statements in it. 
>>> Depending upon the input, the script will run for 5 minutes to an hour. 
>>> I want the user to be able to interrupt the script by clicking on 
>>> another button on the card.  But as I understand it, Rev cannot do that 
>>> because the first button has the focus until the entire script is 
>>> finished running. Is there a way to work around this limitation of Rev?
>>
>> Yes, and the workaround is the preferred method. Running a repeat loop 
>> that long doesn't just lock up Rev, it locks up the whole CPU. Here's the 
>> preferred solution: <http://www.hyperactivesw.com/polling.html>.
>
> It just occured to me that your repeat loop probably doesn't track the 
> mouse, so the link I gave isn't a good reference. What I'd use instead is 
> a "send in <time>" statement that calls a handler repeatedly until the 
> work is done. This will avoid taking all the CPU cycles too, because a 
> time slice is given to other processes in between the "send"s.
>
> A simple example:
>
> on mouseUp -- the button that starts the processing
>  set the cProcessFlag of me to true
>  send "doProcess" to me in 1 millisecond -- can be adjusted
> end mouseUp
>
> on doProcess
>  if <some quit condition; maybe the data is empty, etc> or \
>   the cProcessFlag of me = false then
>    set the cProcessFlag of me to false -- in case the quit condition got 
> us here
>   else
>    doSomeProcessing
>    send "doProcess" to me in 1 millisecond
>  end if
> end doProcess
>
> And in the button that interrupts the processing:
>
> on mouseUp
>   set the cProcessFlag of btn "start button" to false
> end mouseUp
>
> -- 
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> 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 




More information about the use-livecode mailing list