Timer, oTimer and qTimer Functions

Purpose

Return a value of the time elapsed since Windows started in varying time intervals.

Syntax

# = Timer

% = oTimer

# = qTimer

Description

Timer returns the time as a Double in seconds. The internal resolution is _TimerFreq.

oTimer is compatible to GFA-BASIC 16 Timer and returns the time since the Windows start in milliseconds as a 32-bit integer value with a resolution of this timer of 1 millisecond. oTimer is slower than Timer and the resolution of oTimer (milliseconds as an Integer value) is also smaller than that of Timer (1/1.2 million (_TimerFreq )).

Finally, qTimer returns the time as a Double like Timer but has a frequency of approximately 55 milliseconds (the 18.2hz of the Timer Interrupt); qTimer corresponds to the VB function Timer.

Example

FullW 1 : AutoRedraw = 1

Global f1# = .4, f2# = .85, _

w1# = 35, w2# = 5

f1 = .4, f2 = .85

Color RGB(0, 255, 0)

Local t# = Timer, qt# = qTimer, ot% = oTimer

xdraw 100, 130, 160, 100

t# = Timer - t#, qt# = qTimer - qt#, ot% = oTimer - ot%

Color 0

Print AT(1, 1); "Time according to Timer function: "; Format(t#, "0.###"); " secs"

Print AT(1, 2); "Time according to oTimer function: "; Format(ot% / 1000, "0.###"); " secs"

Print AT(1, 3); "Time according to qTimer function: "; Format(qt# * 10, "0.###"); " secs"

Do

Sleep

Loop Until Me Is Nothing

 

Proc xdraw(x, y, l, r)

Local x1#, y1#

RGBColor RGB(0, 255 - l, 0)

Draw "ma" x, y, "tt" r, "fd", l

x1 = Draw(0), y1 = Draw(1)

If l > .5

xdraw x1, y1, l * f1, r + w1

xdraw x1, y1, l * f1, r - w1

xdraw x1, y1, l * f2, r + w2

EndIf

EndProc

Displays the time taken to draw the graphical image.

Remarks

Timer is not compatible with GFA-BASIC 16, because it now returns seconds, instead of milliseconds. oTimer is compatible with GFA-BASIC 16.

See Also

_TimerCount, _TimerFreq, TimerQ.

{Created by Sjouke Hamstra; Last updated: 09/05/2020 by James Gaite}