TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: Everybody..
from: Hans Andersson
date: 2003-07-10 17:33:10
subject: Timer,,,

'NOTE! DEF FN functions must be the last include file
 
TYPE TimerT
  started AS SINGLE
  now AS SINGLE
  stoptime AS SINGLE
END TYPE
 
DECLARE SUB TimerStart (Self AS TimerT, Secs!)
DECLARE FUNCTION TimerCntDwn% (Self AS TimerT)
DECLARE FUNCTION TimerClock! (Self AS TimerT)
 
 
DEF FNTimerStart! (delay!)
FNTimerStart! = TIMER + delay!
END DEF
 
DEF FNTimerCntDwn% (stoptime!)
'Note! max time 1 hour delay on midnight roll over
timeleft! = stoptime! - TIMER
IF timeleft! > 3600 THEN '24:00 roll over
   timeleft! = timeleft! - (TIMER + 86400)
END IF
FNTimerCntDwn% = (timeleft! > 0!)
END DEF
 
 
' --------------------------cut "timer.inc" here
---------------------------
REM '$INCLUDE: 'timer.inc'
REM Compile and set the pc time to 23:59 and set timeout time on the
REM command line to test the midnight roll over
CONST MxSECSxINxDAY = 86400
 
 
DIM clock AS TimerT
 
IF MxSECSxINxDAY  (3600 * CLNG(24)) THEN
   PRINT
   PRINT "FATALE INTERNAL ERROR"
   STOP
END IF
 
CLS
delay! = VAL(COMMAND$)
IF delay! = 0 THEN delay! = 1.5
PRINT "START TIMER TEST FUNCTION"
 
start! = TIMER
CALL TimerStart(clock, delay!)
DO
  GOTO Skip
  used! = CLNG(TimerClock!(clock))
  IF used!  old! THEN
      PRINT used!; " ";
      old! = used!
   END IF
Skip:
LOOP WHILE TimerCntDwn%(clock)
 
PRINT
PRINT "RESULT Timer Delay "; TIMER - start!
 
PRINT
PRINT "START TIMER TEST DEFN "; delay!
 
start! = TIMER
clock2! = FNTimerStart!(delay!)
DO: LOOP WHILE FNTimerCntDwn%(clock2!)
 
PRINT "RESULT DEFN Timer Delay "; TIMER - start!
PRINT "END OF UNIT TEST"
 
FUNCTION TimerClock! (Self AS TimerT)
IF Self.now = 0 THEN dummy% = TimerCntDwn%(Self)
TimerClock! = Self.now - Self.started
END FUNCTION
 
FUNCTION TimerCntDwn% (Self AS TimerT)
 
Self.now = TIMER
IF Self.now < Self.started THEN Self.now = Self.now + MxSECSxINxDAY
TimerCntDwn% = (Self.stoptime >= Self.now)
 
END FUNCTION
 
SUB TimerStart (Self AS TimerT, TimeOutSecs!)
 
Self.started = TIMER
Self.stoptime = Self.started + TimeOutSecs!
Self.now = 0
 
END SUB
 


--- Maximus/2 3.01
* Origin: TankBaren, +46-8-4467316 (2:201/209)
SEEN-BY: 633/267 270
@PATH: 201/505 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.