TIMER fuction

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Dr. D'nar
Newbie
Posts:6
Joined:Tue Sep 28, 2004 10:49 pm
TIMER fuction

Post by Dr. D'nar » Tue Sep 28, 2004 11:11 pm

How accurate can the TIMER fuction be? I tried INT(TIMER*100) in the following snippet:

Code: Select all

pause:
start! = INT(TIMER * 100)
stp! = start! + waittime!
DO
curnt! = INT(TIMER * 100)
LOOP UNTIL stp! = curnt!
RETURN
and it locks up. I tried using >= but that doesn't change much...

Guest

Post by Guest » Fri Oct 01, 2004 5:07 am

sounds like an infinite loop.
Since timer is based on the computer clock, it would probably be 24
hours until the statement would be true.

Dr. D'nar
Newbie
Posts:6
Joined:Tue Sep 28, 2004 10:49 pm

Post by Dr. D'nar » Sat Oct 02, 2004 5:02 am

Works when I use *10.

Guest

Post by Guest » Fri Nov 05, 2004 5:58 pm

You posted:

Code: Select all

pause: 
start! = INT(TIMER * 100) 
stp! = start! + waittime! 
DO 
curnt! = INT(TIMER * 100) 
LOOP UNTIL stp! = curnt! 
RETURN
Let's suppose that, at starting, TIMER = 4000.0, and waittime! = 10.
So,
start! = 400000 and
stp! = 400010

By the time you get to the end of your loop, some time has passed, and
curnt! may now be 400011, so that your
LOOP UNTIL 400010 = 400011
will not be true, and, from then on, it will continue to loop forever.

Your try of
LOOP UNTIL 400010=>400011
also produces an infinite loop. You must reverse your thinking, so:
LOOP UNTIL stp! <= curnt
which would read, for my example:
LOOP UNTIL 400010 <= 400011
which, since it is, stops the loop. That is, whenever the current time exceeds the stop time, the loop will finish.

Give it a try!

Ralph A.

Post Reply