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


QTIMER Component

QTimer implements the Windows API timer functions.

QTimer Properties
Field Type R/W Default Support





Enabled INTEGER RW True WXG
Interval INTEGER RW WXG
Interval determines the amount of time, in milliseconds, that passes before the timer component initiates another OnTimer event.
Tag INTEGER RW WXG


QTimer Events
Event Type Occurs when... Params Support





OnTimer VOID Timer interval elaspes 0 WXG


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 Timer AS QTimer, Timer2 AS QTimer
DIM Form AS QFORM
DIM Label1 AS QLABEL, Label2 AS QLABEL
DIM Label3 AS QLABEL

SUB TimerOver
  Timer.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

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

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

FORM.OnKeyPress = KeyPressed
FORM.SHOWMODAL

Prev ComponentContentsNext Component