timer eventually speeds up
Posted: Sun Aug 30, 2015 3:22 pm
Hello!
My timer is buggy. I send updatetimer on preloadcard, and the first time the card is loaded it works like a charm. When I leave the card, gTimerOn is false, but updatetimer is still being sent. Then, when I reload the card, updatetimer is a sent a second time, which stacks onto the first.
Now, I was able to solve this problem by moving the last line of the following code INTO the conditional, and sending updatetimer again with a button that unpauses it (I need to be able to pause and unpause the timer, but the timer is only reset when the card is loaded). That way updatetimer "dies out" and can't stack when I put false into gTimerOn.
I was just wondering if there was a more elegant way of controlling/limiting messages being sent to a card, e.g. when you close the card, all pending messages are cancelled. I tried writing some code to that effect (e.g. cancel the last line of the pendingmessage) but got a lot of error messages so obviously I wasn't doing it correctly.
My timer is buggy. I send updatetimer on preloadcard, and the first time the card is loaded it works like a charm. When I leave the card, gTimerOn is false, but updatetimer is still being sent. Then, when I reload the card, updatetimer is a sent a second time, which stacks onto the first.
Now, I was able to solve this problem by moving the last line of the following code INTO the conditional, and sending updatetimer again with a button that unpauses it (I need to be able to pause and unpause the timer, but the timer is only reset when the card is loaded). That way updatetimer "dies out" and can't stack when I put false into gTimerOn.
Code: Select all
on updatetimer
global gTimerOn, gSeconds
if gTimerOn is true then
add 1 to gSeconds
put gSeconds into fld "Timer"
end if
send updatetimer to me in 1 second
end updatetimer