1. You cannot cancel a timer once started. 2. You can start subsequent timer. 3. You can use 'user data' such as sequence number to pass along with a timer. User data will be used as parameter to function when timer is called. 4. This user data can be a sequence number in stored in a variable for later reference.
// In activity script var currSeqNum = 0; function myTimerFunction(seqAtTimeOfTrigger) { if (currSeqNum === seqAtTimeOfTrigger) { // do something as user has not reset/restarted timer. // jump back. } }
In the page script where you need to start the timer, you will need to add prontoscript.
// Page setupOrRestartTimer();
Note that you can take this farther and use only a single active timer by keeping track of time remaining before JumpBack must occur. This is the more resource-friendly approach as there are only 64 allowed timers. That is, if you have a long timeout period and user presses 65 buttons, that 65th press will fail to start a timer and you will then lose JumpBack capability because timers 1 to 64 above will not act because sequence number does not match.
I leave this as an exercise for you to experiment with.
Philips did something like this in the RS232 scripts for Denon/Marantz receivers. Admittedly, their code is rather complicated and sometimes difficult to read but it does the job.