Liberty BASIC Help Online |
The Timer Statement
Liberty BASIC includes a timer statement which uses the computer's hardware timer. Most PCs have a timer with a resolution of approximately 56 milliseconds which ticks 18 times a second. The timer allows the addition of a clock to a program, or or it allows the program to wake up every few seconds to check for some condition, or it can be used to control the rate of animation of a game. There are other uses as well.
The TIMER command specifies how many milliseconds to wait between timer signals. One second is 1000 milliseconds. It also specifies a routine to serve as an event handler. The timer may be turned off and then back on.
Here is a short example:
timer 3000, [threeSeconds]
wait
[threeSeconds]
timer 0
confirm "Three seconds have passed. Do it again?"; repeat
if repeat then
timer 3000, [threeSeconds]
wait
end if
end
Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/