Re: [DOS] How to code for a time delay? - DONE

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

Alex Caracatsanis wrote:

> }}}
<eucode>
> 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
> </eucode>
{{{


Your code will never work as 'interval' is always calculated as zero.

Try this ...

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


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

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

Search



Quick Links

User menu

Not signed in.

Misc Menu