Pausing a timer
It can be important to have the ability to stop or pause a timer once it is started. The difference between stopping and pausing a timer is in keeping track of where the timer was when it was interrupted. In this recipe, you'll learn how to pause a timer. Of course, if you never resume the timer, then the act of pausing it has the same effect as stopping it.
How to do it...
Use the following steps to create a count-up timer and pause function:
- Create a new main stack.
- Place a field on the stack's card and name it
timerDisplay
. - Place a button on the stack's card and name it
Count Up
. - Add the following code to the
Count Up
button:on mouseUp local pTime put 0 into pTime put pTime into fld "timerDisplay" countUpTimer pTime end mouseUp
- Add the following code to the
Count Up
button:on countUpTimer currentTimerValue add 1 to currentTimerValue put currentTimerValue into fld "timerDisplay" if currentTimerValue < 60 then send "...