Futurebasic/Language/Reference/on timer

ON TIMEREdit

StatementEdit

(+) Appearance (+) Standard Console

SyntaxEdit

ON TIMER(interval) ¬
{FN userFunction|GOSUB{lineNumber|"stmtLabel"}}
TIMER END
TIMER OFF

RevisedEdit

January 2, 2001 (Release 4)

DescriptionEdit

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 interval 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 interval is positive, it specifies the timer interval in seconds. If interval is negative, then ABS(interval) specifies the interval in ticks (a tick is approximately 1/60 second). Setting interval to zero does not initiate timer events; in this case, you can use the TIMER statement to initiate timer events later in your program.

After timer events have been initiated, FB checks its internal timer whenever a HANDLEEVENTS statement is executed. If FB checks its timer and finds that at least interval seconds (or ABS(interval) 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 TIMER OFF or TIMER END.

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 HANDLEEVENTS as often as possible.

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

See AlsoEdit

TIMER; HANDLEEVENTS