Article ID: 20572
Article Last Modified on 10/20/2003
' This program requires QuickBASIC.
ToolBox "i"
ticks& = 0
ToolBox "LQ", &H975, ticks&
PRINT "About"; ticks&\60 ;"seconds have elapsed since startup."
Note that the value of TICKS is not guaranteed to be exact.
' TICKS ' This program is designed for Microsoft BASIC Interpreter 3.00 and ' earlier, and for the BASIC Compiler 1.00. DEF FNtic=PEEK(365) ' FNtic counts 0 to 255 by 60ths of a second. loop: seconds=0 ' Seconds start out as 0. PRINT "Timing is done between your next two keystrokes:" nokey: a$=INKEY$ IF a$="" GOTO nokey ' Start timing at key press: ON TIMER (1) GOSUB handler ' Every second, increment seconds. TIMER ON ' Turns on timer event trapping. startic=FNtic ' Initial 60ths of a second. nopress: a$=INKEY$ IF a$="" GOTO nopress ' Wait for 2nd press. endtic=FNtic ' Final 60ths of a second. ticdif=ABS(endtic-startic) ' Adjust for rollover (255 to 0) of tic count: IF endtic=>startic THEN ticks=ticdif ELSE ticks=256-ticdif tenths=(ticks MOD 60)/60 ' Use MOD function, convert 60ths>10ths. total=seconds+tenths PRINT "elapsed time="total TIMER OFF ' Turn off second counting until a key is pressed. GOTO loop handler: seconds=seconds+1 : RETURN
Additional query words: BasicCom MQuickB
Keywords: KB20572