QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

A TIMER statement enables, turns off or stops timer event trapping. QBasic only uses the base timer, but QB64 can run many.

Syntax

QB

TIMER {ON STOP OFF}

QB64

TIMER(number%) {ON STOP OFF FREE}

Parameter(s)

Description

QB64 only

QB64 Timing Alternatives

Example(s)

How to update the time while PRINT 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 

NOTE: SLEEP will be interrupted in QBasic.

See Also