Re: [DOS] Code for a time delay? - THANKS DEREK

new topic     » topic index » view thread      » older message » newer message

Derek Parnell wrote:
> 
> Alex Caracatsanis wrote:
> > }}}
<eucode>
> > -- code
> > </eucode>
{{{

> 
> Your code will never work as 'interval' is always calculated as zero.
> 
> Try this ...
> 
> }}}
<eucode>
> constant MAX_STARS = 200,
>          SCREEN = 1,
>          TRUE = 1,
>          DELAY = 0.04 -- wait 0.04 secc
> 
> atom stopTime
> 
> stopTime = 0
> 
> 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
> 
>      stopTime = time() + DELAY
>      while time() < stopTime do
>      end while
> end for
> </eucode>
{{{

> 
> -- 
> Derek Parnell
> Melbourne, Australia
> Skype name: derek.j.parnell

Oops - of course! I outsmarted myself. In my working code I had:
startTime = time()
while TRUE do
    stopTime = time()
    if (stopTime - startTime >= DELAY) then exit end if
end while

I've learnt my lesson: don't show off - especially with untested code! :)

Thanks Derek.

Alex

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu