Computer Science Canada

How to insert a timer (seconds)

Author:  hq78 [ Sat Dec 18, 2004 1:38 pm ]
Post subject:  How to insert a timer (seconds)

Hello, I would like to know if anyone here knows how to add a timer in a loop in seconds. Thanks in advance!

Author:  Cervantes [ Sat Dec 18, 2004 1:45 pm ]
Post subject: 

There sure is a way to do it Smile Time.Elapsed.
code:

loop
    locate (1, 1)
    put Time.Elapsed / 1000 : 6 : 3, " seconds have passed since this program began."
    if Time.Elapsed / 1000 > 10 then
        locate (2, 1)
        put "That's a long time.  Hop to it!"
    end if
end loop

Note that Time.Elapsed returns a value in milliseconds. Thus, divide that value by 1000 to get a value in seconds.

Author:  hq78 [ Sat Dec 18, 2004 5:14 pm ]
Post subject: 

thank you very much!

Author:  zomg [ Sat Dec 18, 2004 11:28 pm ]
Post subject: 

doesnt time.elapsed measure cpu time not actual time? Confused

Author:  Neo [ Sat Dec 18, 2004 11:48 pm ]
Post subject: 

shadow master wrote:
doesnt time.elapsed measure cpu time not actual time? Confused


Im pretty sure its the actual length of time since starting the program.

Author:  Cervantes [ Sun Dec 19, 2004 8:25 am ]
Post subject: 

shadow master wrote:
doesnt time.elapsed measure cpu time not actual time? Confused

ssshh.... Shifty

Author:  Mazer [ Sun Dec 19, 2004 9:34 am ]
Post subject: 

shadow master wrote:
doesnt time.elapsed measure cpu time not actual time? Confused

Turing Reference wrote:
The Time.Elapsed function returns the amount of time since a program (process) started running. The number of milliseconds since the program started running is returned.

Well. Nope. It's just that it's not always accurate.

Author:  Cervantes [ Sun Dec 19, 2004 9:42 am ]
Post subject: 

As Delos said, it varies from CPU to CPU.


: