Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some TIMER help!!!!
#1
Ok, I know how TIMER works, but i have some trouble w/it.

Here are the things i want to do w/it:
-RESET it, so TIMER = 0.0000
-Use an ON TIMER(time!) gosub sub.routine
-Create a TIMEd event:
Code:
time! = TIMER
sleep 1
stop.time! = timer
second = stop.time! - time!
'Holds one second to the variable second
with that, I want to be able to make QB time, where in a game 5 minutes goes by and 5 seconds goes by at the same time.

:bounce:
so, it you could help out a bit, please do

cya
Reply
#2
Reset the timer? I'm not sure, but I don't think you want to do that...First, it involves (probably, this is just guessing) complicated CALL ABSOLUTE routines. Second, it's a tad...er...dangerous. (Again, I think.)

Your second question:
Code:
TIMER ON
ON TIMER(1) GOSUB sub.routine
DO:LOOP
sub.routine: PRINT "X"
RETURN
This will print 'X' every 1 second. How it works: the parameters that ON TIMER (n) GOSUB sub.routine takes is the interval of time (in seconds) between jumps to the sub.routine subroutine.

Your last question I don't quite understand...If you want to make a the 'second' variable equal to one, then make all of those variables in the program long integers, Since the delay is not absolutely exactly 1 second. So, if you make all variables integers, it'll always round the 'second' variable to 1 second (almost always, anyway).
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#3
qb's event trapping kinda sucks, and it's unnecessary.

here:
Code:
basetime = TIMER ' get the number of seconds since midnight
count1 = basetime
count2 = basetime

do until inkey$ <>""
locate 1, 1: print timer - count1
locate 2, 1: print timer - count2

if timer - count1 > 5 then
  print "5 seconds has passed"
  count1 = timer
end if

if timer - count2 > 300 then ' 5 minutes
  print "5 minutes has passed"
  count2 = timer
end if
loop
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)