Difference between revisions of "ON TIMER (n)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
Line 31: Line 31:
  
  
''See also:'' [[TIMER (statement)]], [[TIMER]]
+
''See also:'' [[TIMER (statement)]], [[TIMER]], [[ON...GOSUB]]
  
  

Revision as of 03:27, 7 October 2009

The ON TIMER statement sets the number of seconds to wait to execute a GOSUB procedure.


Syntax: ON TIMER(seconds) GOSUB linelabel


  • The maximum number of seconds cannot exceed 86400.
  • A TIMER ON statement must be made before an ON TIMER statement can be enabled.
  • TIMER OFF disables timer event trapping. Events will not be remembered in a subsequent ON TIMER statement.
  • TIMER STOP will remember previous events when enabled by a TIMER ON statement and the ON TIMER statement(s) will be executed immediately.
  • ON TIMER events will interrupt SLEEP calls.


Example: How to update the time while PRINTing at the same time in a program.

TIMER ON ' enable timer event trapping
LOCATE 4, 2 ' set the starting PRINT position
ON TIMER(10) GOSUB Clock ' set procedure execution repeat time
DO WHILE INKEY$ = "": PRINT "A"; : SLEEP 6: LOOP
TIMER OFF
SYSTEM
Clock:
row = CSRLIN ' Save current print cursor row.
col = POS(0) ' Save current print cursor column.
LOCATE 2, 37: PRINT TIME$; ' print current time at top of screen.
LOCATE row, col ' return to last print cursor position
RETURN


See also: TIMER (statement), TIMER, ON...GOSUB



Navigation:

Go to Keyword Reference - Alphabetical

Go to Keyword Reference - By usage