Page 1 of 1

TIMER fuction

Posted: Tue Sep 28, 2004 11:11 pm
by Dr. D'nar
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...

Posted: Fri Oct 01, 2004 5:07 am
by Guest
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.

Posted: Sat Oct 02, 2004 5:02 am
by Dr. D'nar
Works when I use *10.

Posted: Fri Nov 05, 2004 5:58 pm
by Guest
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.