Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timer Problems
#1
Hi,
In my code I have this
Code:
DO
        a=a+1
        key$=inkey$
loop until key$<>"" OR a=100000

my problem is that on a 133Mhz the loop takes 1-2 mins to complete but on 450Mhz it takes 10-20secs and I want a way to replace the a=a+1 etc with a better timer, any ideas?
Reply
#2
TIMER
Reply
#3
lol

----

ray if i understand you correctly, if you want your program to stop for one second then:

Code:
stimer = timer
do
loop until timer > stimer + 1

if not, then whatever.
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Reply
#4
optimize that like this:

Code:
stimer = timer + 1
do
loop until timer > stimer

that way the 'add' operation only happens once =)
Reply
#5
If your delays are bigger than 1/18 second TIMER is ok
Code:
d!=2.2           'delay in seconds        
t!=timer+d!
do
loop until (timer!>t!) or (timer<d!) or (len(inkey$))

the condition timer<d! is to avoid getting stuck at midnight
Antoni
Reply
#6
i see,

Code:
stimer = timer
do
if timer < stimer then stimer = 86400 - stimer: stimer = 0 - stimer
loop until timer > stimer + 15

this also deals with midnight...i think :???:

edit: i fixed it and it does indeed work when run past midnight Smile
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Reply
#7
Quote:i see,

Code:
stimer = timer
do
if timer < stimer then stimer = 86400 - stimer: stimer = 0 - stimer
loop until timer > stimer + 15

this also deals with midnight...i think :???:

edit: i fixed it and it does indeed work when run past midnight Smile
I've never cared for the midnight bug, and never had any reports of anyone having it happen to them.. I guess it's pretty rare for people to run <1 sec timer based delays/loop exactly at midnight Tongue
Reply
#8
that's what thought. but i guess that's why they call them contingencies.

i guess if you have a game that uses it every second or somthing.
quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Reply
#9
because i want it to wait 1min30secs then start the loop again will this work:
Code:
stimer = timer+90
key$=""
do
key$=inkey$
if stimer>=timer then turncomplete=TRUE
loop until key$<>"" OR turncomplete=TRUE
Reply
#10
there is still a problem now the screen redraws 15 times in 1 sec then goes at the exceted speed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)