Skip to content
aanon4 edited this page Sep 22, 2014 · 1 revision

Syntax

TIMER <0-3>, <timeout in milliseconds> [REPEAT] GOSUB <line number>

TIMER <0-3> STOP

Description

It's often useful to run bit of your program either at a particular time in the future, or repeatedly every so many seconds. To do this we use TIMERS. Current four timers are supported. Each time can be created to run a specific section of the Basic program after a given number of milliseconds has elapsed. A timer may choose to keep repeating (e.g. execute every 5 seconds) or just run once (e.g. execute after 5 seconds and then stop).

For example:

10 TIMER 1, 2000 REPEAT GOSUB 1020
...
1020 PRINT "Hello"
1030 RETURN

The above example sets up timer 1. Every 2000 milliseconds, repeatedly, it will run the subroutine at line 1020. This line simply prints "Hello" and then finishes. To stop this timer we can simply execute:

TIMER 1 STOP
Clone this wiki locally