Re: [DOS] How to code for a time delay? - DONE
- Posted by Alex Caracatsanis <sunpsych at ncable.com.au> May 28, 2007
- 614 views
Thanks alot for your replies, gents. Chris, I've taken a copy of your solution for future reference, as it is beyond my capabilities at the moment. Don, thanks for your procedure delay(), using time(). And Juergen, thanks for demonstrating use of tick_rate(). I set this problem as an exercise for me, to learn how to use routines related to time, and I expected some challenges with time(), sleep(), and tick_rate(). With your help I've seen examples of all three. For what it's worth, here's the solution I devised by myself - part trial, part intuition. I suspect that it's not the most efficient, but it seems to work in this limited example.
constant MAX_STARS = 200, SCREEN = 1, TRUE = 1, DELAY = 0.04 -- wait 0.04 secc atom startTime, stopTime, interval startTime = 0 stopTime = 0 interval = (stopTime - startTime) for i = 1 to MAX_STARS do puts( SCREEN, "*" ) -- new line/tab across every 60 characters if remainder( i, 60 ) = 0 then puts( SCREEN, "\n\t") end if startTime = time() while TRUE do stopTime = time() if (interval >= DELAY) then exit end if end while end for
If you feel moved to comment or improve on this code, I'll gladly accept the tuition. In any case, thank you all very much for your help with this. Alex Caracatsanis