TIMER

TIMER N

CREATES A SYSTEM OBJECT TIMER AND ALLOCATES IT NUMBER N AS REFERENCE

  • Type: Command
  • Parameter: 1
  • Group: System Objects Creation

ACTION

The command creates a system object TIMER, and allocates it a number N. The number N will be used to designate the TIMER.

The created TIMER can then be used through the appropriated commands (ON_TIMER, TIMER_INTERVAL, TIMER_ON, TIMER_OFF), but is not visible.

A TIMER can generate the event : ON_TIMER.

Remark 1: the TIMER is active when created and its period is 1000 milli-seconds.

Remark 2: a TIMER can be deactivated by TIMER_OFF and reactivated by TIMER_ON.

Remark 3: its period (in milli-second) can be modified by TIMER_INTERVAL.

SYNTAX: TIMER N

  • N = system object number (integer or real). Must be greater than 0 and less than or equal to the allowed maximum number of system objects.

USE

  • A TIMER is used to execute periodically a sub-routine (ON_TIMER).

ERROR

  • If number N is not a correct expression.
  • If number N exceeds the allowed maximum number of system objects.
  • If number N is less than or equal to 0.
  • If number N is already used for a system object number.

EXAMPLE

rem each second, displays a number from 1 to 10 then stops

label count

dim i%

rem create a TIMER

timer 1

on_timer 1,count

end

count:

i%=i%+1

print i%

if i%=10 then timer_off 1

return

SEE ALSO

ON_TIMER

TIMER_INTERVAL

TIMER_ON

TIMER_OFF

TIMER_OFF_ALL