QBasic / QB64 Discussion Forum      Other Subforums, Links and Downloads
 

 Return to Index  

Delay in range .054 second to 11 days

December 2 2007 at 4:22 PM
  (Premier Login iorr5t)
Forum Owner

 

FAQ012:  How to delay.

Got these results using the program below:

Seconds: 7200
 7200.066

Not bad, considering that I minimized the DOS Window and did other stuff.

Conclusion: We finally have a delay routine that works for any interval of time > .054 second - Even 999999 (About 11.5 days) even if daylight savings time changes or the user manually resets the clock for some reason. And of course, no problem crossing midnight.

Mac

DECLARE SUB Delay (Seconds AS SINGLE)
DO
  INPUT "Seconds: ", s: IF s = 0 THEN SYSTEM
  t = TIMER: Delay s: PRINT TIMER - t
LOOP

SUB Delay (Seconds AS SINGLE)
DIM Goal AS LONG: Goal = Seconds * 256
DIM Elapsed AS LONG, t1 AS LONG, t2 AS LONG
t1 = TIMER * 256
DO
  DO: t2 = TIMER * 256: LOOP WHILE t2 = t1
  IF ABS(t2 - t1) < 200 THEN
    Elapsed = Elapsed + t2 - t1
  ELSE
    Elapsed = Elapsed + 14
  END IF
  t1 = t2
LOOP WHILE INKEY$ = "" AND Elapsed < Goal
END SUB

 



    
This message has been edited by iorr5t on Dec 2, 2007 4:28 PM


 
 Respond to this message   
 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement