ON_TIMER

ON_TIMER N,L

EXECUTES THE PROGRAM FROM LABEL L WHEN THE SYSTEM OBJECT NUMBER N TRIGGERS

  • Type: Command
  • Parameters: 2
  • Group: Events

ACTION

The command ON_TIMER N,L assigns a label (which must be defined in the program) from which the program will run every time the TIMER designated by the number N is triggered.

The system object must be of the type TIMER.

SYNTAX: ON_TIMER N,L

  • 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.
  • L = label.

USE

  • The command ON_TIMER is used to associate a periodic event happening to a system object TIMER, to a program location (defined by the label L).
  • When the event occurs, the program named by the label is executed.

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 0.
  • If system object number N does not exist.
  • If system object number N is not of the type : TIMER.
  • If the label L does not exist.
  • If L is not a correct label name.

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

TIMER

TIMER_INTERVAL

TIMER_ON

TIMER_OFF

TIMER_OFF_ALL