How to kill a wait routine?

Posted by Whininguser on Sat 05 Jan 2013 02:45 AM — 5 posts, 20,500 views.

Canada #0
This is the wait routine I'm using:

http://www.gammon.com.au/forum/?id=4956&reply=1#reply1


Suppose I have a function like this:

function my_alias_thread ()

Send ("eat bread")
wait (30)

-- Is there anything I can write here (or elsewhere) to
-- terminate the 30-second wait above? Thanks.

Send ("eat bread")
wait (1)

end
Amended on Sat 05 Jan 2013 02:56 AM by Whininguser
Australia Forum Administrator #1
It could be done, but I'm not at my usual PC right now. The wait (time) is done by a timer which eventually calls coroutine.resume (thread).

If you could work out the thread then you could make something else resume the (main) thing which is waiting.

That is how the wait.match works. You either get a trigger match or a timeout. So if you want to cancel for some other reason you expand that concept.
Canada #2
Suppose the 30-second wait is named "wait_123". The only solution I know is this:

SetTimerOption ("wait_123", "second", "0")

Is there a better way to do it? (Newbie to coroutine)

Australia Forum Administrator #3
You need to look at what the timer does when it expires and do that "right now". It's just code. You don't have to do it when the timer expires.
Canada #4
Got it (I think). Thanks Nick.