Rapid-Q Documentation by William Yu (c)1999-2000 Appendix A: QTIMER

QTIMER Component

QTimer implements the Windows API timer functions. The real resolution of this timer is about 30 - 50 milliseconds, not 1.  If you need better resolution try QDXTIMER. QDXTIMER does not require a DXSCREEN, you should be able to substitute only one QDXTIMER for QTIMER without problems.

QTimer Properties
FieldTypeR/WDefaultSupport





EnabledINTEGERRWTrueWXG
IntervalINTEGERRWWXG
Interval determines the amount of time, in milliseconds, that passes before the timer component initiates another OnTimer event.
TagINTEGERRWWXG


QTimer Events
EventTypeOccurs when...ParamsSupport





OnTimerSUB(Sender AS QTIMER)Timer interval elaspes1WXG


QTimer Examples
' Timer & OnKeyPress example for Rapid-Q by William Yu
'       If no form is visible, Timer will not function.
'       Not for PURE CONSOLE apps, but you're allowed to MIX.

DIM Timer1 AS QTimer, Timer2 AS QTimer
DIM Form AS QFORM
DIM Label1 AS QLABEL, Label2 AS QLABEL
DIM Label3 AS QLABEL

SUB TimerOver
  Timer1.Interval = 100
  I = I + 1
  Label1.Caption = STR$(I)
END SUB

SUB Timer2Over
  Timer2.Interval = 1000
  J = J + 1
  Label2.Caption = STR$(J)
END SUB

SUB KeyPressed (Key AS BYTE)      '' Event returns one parameter
  IF UCASE$(CHR$(Key)) = "Q" THEN
    FORM.CLOSE
  END IF
END SUB

I = 0        ' Undeclared variables are automatically global!
J = 0

FORM.CAPTION = "Timer Example"
FORM.WIDTH = 150
FORM.HEIGHT = 120
FORM.CENTER

Label1.Parent = Form
Label1.Caption = STR$(I)
Label1.Left = FORM.WIDTH/2

Label2.Parent = Form
Label2.Caption = STR$(J)
Label2.Left = FORM.WIDTH/2
Label2.Top = 40

Label3.Parent = Form
Label3.Caption = "Press 'Q' to quit'
Label3.Top = 75

Timer1.Interval = 100
Timer1.Enabled = 1          ' True
Timer1.OnTimer = TimerOver

Timer2.Interval = 1000
Timer2.Enabled = 1          ' True
Timer2.OnTimer = Timer2Over

FORM.OnKeyPress = KeyPressed
FORM.SHOWMODAL

Prev Component Contents Next Component