FAQ012: How to delay.
Got these results using the program below:
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.
DECLARE SUB Delay (Seconds AS SINGLE)
INPUT "Seconds: ", s: IF s = 0 THEN SYSTEM
t = TIMER: Delay s: PRINT TIMER - t
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: t2 = TIMER * 256: LOOP WHILE t2 = t1
IF ABS(t2 - t1) < 200 THEN
Elapsed = Elapsed + t2 - t1
Elapsed = Elapsed + 14
t1 = t2
LOOP WHILE INKEY$ = "" AND Elapsed < Goal