Futurebasic/Language/Reference/on timer

Revised
January 2, 2001 (Release 4)

Description
This statement designates a particular function or subroutine as a timer-event handling routine. A timer-event handling routine is called periodically according to a time interval that you specify.

Setting  to a nonzero value causes timer events to be initiated, which causes FB to periodically check whether it's time to call your routine. If  is positive, it specifies the timer interval in seconds. If  is negative, then   specifies the interval in ticks (a tick is approximately 1/60 second). Setting  to zero does not initiate timer events; in this case, you can use the   statement to initiate timer events later in your program.

After timer events have been initiated, FB checks its internal timer whenever a  statement is executed. If FB checks its timer and finds that at least  seconds (or   ticks) have elapsed since the last time your designated routine was called, it calls your designated routine again.

Timer events are queued. If the timer interval is one second and your program is otherwise occupied for a period of 10 seconds, you will receive 10 timer events as soon as the program becomes idle. You may flush this queue by using or.

Designating a timer-event routine is useful when your program needs to perform periodic activities at particular intervals. To ensure that your timer-event handling routine is called at the right moments, your program should execute  as often as possible.

Note: You can use the  statement to change the timing interval. You cannot disable timer events once they've been initiated.