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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
JamesWebster
Posts: 25
Joined: Sun Aug 07, 2011 11:36 am

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

Post by JamesWebster » Fri Aug 12, 2011 5:57 pm

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!
Last edited by JamesWebster on Sat Aug 13, 2011 8:16 am, edited 1 time in total.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post by mwieder » Fri Aug 12, 2011 6:14 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Sat Aug 13, 2011 1:22 am

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

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post by mwieder » Sat Aug 13, 2011 1:27 am

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.

Post Reply