Qbasicnews.com

Full Version: Timer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Help

[syntax="FB"]
Count = 0
Do
Timei = Timer
Count = Count + 1
Locate 1,1: Print Count
Do: Loop while Timer-Timei <= .1
Loop While Not Multikey(&h1) And Inkey$ <> Chr$(255) + "X"
[/syntax]
What's wrong?
You see when I run it, it prints 1 then it counts up to 2200 really fast then it pauses then it goes up to 44000 really fast then it pauses then it goes up really fast then it pauses, etc. Why? How can I fix it?
Works fine.


It's XP raping you from behind, hard.. with it's friend, Bubba Adcode
ok...can it be fixed?
Remove the inkey$ check, it's what slows you down. The close button will not work then....
Well, then thats ok, I don't need it, thnx

EDIT:
And yet it still doesn't work. Still need help. You see when I make it .5 instead of .1 it does it good at second intervals, but when I do it at anything less than .5 I get what I stated above still.
Depending on what version of Windows you have, TIMER may be using the high resolution win32 timer or not. You may be using the unprecise version.
Secondly, console output under windows is slow, so that may be causing slowdowns every now and then.
Also, try shutting down other apps running in the background before starting your program...
Well, I think I missed the main problem.
In FB the variables are integer by default. so timei=timer rounds to an integer. Make timei single and the bursts will disappear....
Antoni, You hit it on the nose. Thnx

I thought vars in Basic started out defined as singles. So thats why I didn't dim it....heh...any other suprises FB has?

1 Q: whats with the UInteger compared to Integer? What the difference?
:???: Here is your problem: timei = TIMER,. it needs to be timei! = TIMER.. Like this..

Code:
Timei! = Timer
   Do: Loop until (Timer - Timei!) >= .1

:wink: Fixed it for me..

Darn, beatin to it,. lol,. oh well
Quote:1 Q: whats with the UInteger compared to Integer? What the difference?
Unsigned datatypes have no sign bit.

In other words, you can't do negative numbers, but you can do higher positive numbers.
Look:
INT: -2147483648 to 2147483647
UINT: 0 to 4294967295
Pages: 1 2