Page 1 of 1

Solved*Wait/Timer and User Input at the same time

Posted: Fri Aug 12, 2011 5:57 pm
by JamesWebster
Using the wait function I'm trying to create some kind of counter for the user
to see how much time has passed, while he has to input some Information.
The seconds functions is useful for this I'm guessing but I can't seem to find a
way to use it right.

Code: Select all

On Opencard
put 20 into x
         repeat until x = 0
            subtract 1 from x
            wait 1 sec
            put x into fld "Counter"
            end repeat
end Opencard
Thank you very much in advance!

Re: Wait/Timer and User Input at the same time

Posted: Fri Aug 12, 2011 6:14 pm
by mwieder
I normally try to avoid wait commands for this reason. Here's an alternate approach:

Code: Select all

local x

On Opencard
  put 20 into x
  bumpCounter
end Opencard

on bumpCounter
  if x is not 0 then
    put x into field "Counter"
    subtract 1 from x
    send "bumpCounter" to me in 1 sec
  end if
end bumpCounter
The idea being that the bumpCounter routine triggers itself once a second until it's done this 20 times. Since it's running independently of anything else, the user is free to input things or do anything else at the same time.

Re: Wait/Timer and User Input at the same time

Posted: Sat Aug 13, 2011 1:22 am
by dunbarx
What Mark said.

Implied. The wait command locks you out of absolutely everything until it is done. Old fashioned, unless you actually need it.

Craig Newman

Re: Wait/Timer and User Input at the same time

Posted: Sat Aug 13, 2011 1:27 am
by mwieder
as an addendum, you *can* "wait with messages", which will allow other events some breathing space, but in this case you'll still be stuck in your repeat loop, so that won't get you out of trouble.