Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to insert a timer (seconds)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hq78




PostPosted: 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!
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Dec 18, 2004 1:45 pm   Post subject: (No 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.
hq78




PostPosted: Sat Dec 18, 2004 5:14 pm   Post subject: (No subject)

thank you very much!
zomg




PostPosted: Sat Dec 18, 2004 11:28 pm   Post subject: (No subject)

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




PostPosted: Sat Dec 18, 2004 11:48 pm   Post subject: (No 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.
Cervantes




PostPosted: Sun Dec 19, 2004 8:25 am   Post subject: (No subject)

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

ssshh.... Shifty
Mazer




PostPosted: Sun Dec 19, 2004 9:34 am   Post subject: (No 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.
Cervantes




PostPosted: Sun Dec 19, 2004 9:42 am   Post subject: (No subject)

As Delos said, it varies from CPU to CPU.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: