OW
Posts a bit
Posts: 100
|
Post by OW on Aug 18, 2009 2:32:16 GMT -5
So I'm making a little 1-9 multiplication flash card/timed test application to help me , and possibly others memorize it easier, but I have a question about the performance counter and tick counter.
The programmers guide say that they time the number of milliseconds since your computer is turned on. Can I make it so that it can time the number of milliseconds since you started the loop (test)?
Here is my code, BTW It's fully functional, I'm just adding some bells and whistles.
Dim X,Y,ans,xpos,ypos,wWin,hWin,ans$,flash,test x =Rnd()%9+1 y =Rnd()%9+1 ans = x*y
print "Flash cards or Test?" input ans$ if ans$ = "f" then flash = true cls endif if ans$ = "t" then test = true cls endif while flash = true locate 0,0 print x Locate 0,1 print "X" locate 0,2 print y locate 0,3 print ans if ScanKeyDown(VK_SPACE) then cls x = Rnd()%9+1 y =Rnd()%9+1 sleep(190) ans = x*y locate 0,0 print x locate 0,1 print "X" locate 0,2 print Y locate 0,3 print ans drawtext() endif wend
While test = true locate 0,0 print x locate 0,1 print "x" locate 0,2 print Y locate 0,3 input ans$ if ans$ = ans then cls x = Rnd()%9+1 y =Rnd()%9+1 sleep(190) ans = x*y endif wend
|
|
|
Post by matthew on Aug 18, 2009 5:12:02 GMT -5
Hi OW, you'll need to do something like the following.
dim startTime, EndTime, elapsedTime
while true
startTime = PerformanceCounter() ' Start the timer Sleep(1000) ' Do stuff here
endTime = PerformanceCounter() ' End the timer
elapsedTime = (endTime - startTime) ' Time taken in milliseconds printr elapsedTime ' Print time taken in milliseconds elapsedTime = 0 ' Reset time taken to zero
wend
|
|
OW
Posts a bit
Posts: 100
|
Post by OW on Aug 18, 2009 13:26:11 GMT -5
Hmm, ok, but how do I stop the timer automatically, at the set time?
Could I say "if PerformanceCounter() = however many milliseconds are in 3 minutes then whatever?
|
|
|
Post by Nicky Peter Hollyoake on Aug 18, 2009 14:36:24 GMT -5
if INT((StartTime - EndTime) / 1000.0) >= 3 then END endif - Nicky
|
|
|
Post by twasik4 on Nov 23, 2009 9:07:11 GMT -5
Thanks, glad I found this I need something like this for my biology experiment. =D
|
|
|
Post by Darkjester on Nov 24, 2009 20:06:01 GMT -5
biology experiment + basic4gl?
|
|
|
Post by shadow008 on Nov 25, 2009 8:08:31 GMT -5
yeah.... i already did it for him -.- it needed background colors which was just perfect for b4gl!... oh yeah, and performancecounter.
|
|