Stop a timer with a panel state change on onclick

Long story short. I have a dynamic panel which has one state that includes a countdown timer. It starts at 10 and counts down to 0 in 1000ms increments.

As it counts down, it also decreases the variable associated with it by one, which is where the text gets its value from as well.

(The timer is like this:
Starts at 10
Wait 1000ms…
Decrease variable by 1
Wait 1000ms…
Decrease variable by 1
Wait 1000ms…
Decrease variable by 1
Wait 1000ms…
Decrease variable by 1

So the text counts down to 0 as the variable does. Easy so far.

What I want to do is have a button that stops the countdown. What I have now is a button that resets the variable back to 10, but then keeps counting down until the original timer event stops.

So if it gets down to 4, then I click on the button to reset the variable, it goes to 10, but keeps counting down to 7 because that’s what’s left from the original event.

What I want it to do is to set the variable to 10 AND stop the countdown. I’m sure this is way easier than I’m making it out to be.

Hi jteason

Not sure if this is on the money - but here’s a stop / start counter.

File here - have commented the scripts for explanation and shown a variable value on the screen.

stopstartcounter.rp (53.9 KB)

Not sure this will work with my setup, but I can modify mine to see if this approach will work.

Thanks so much!!

If you want to have any control over it then doing a series of Wait actions won’t work since you can never stop those. Instead you need an Event/Fire Event loop with conditions, like in the example.

To stop the timer you change something, usually a variable value, so the condition on the timer fails and it doesn’t proceed. To start it again, you allow the condition to succeed. The loop continuously runs so it checks the condition ever iteration of the loop.

1 Like