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

Username:   Password: 
 RegisterRegister   
 Storing Times in Variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DarkMastermind




PostPosted: Mon Jun 20, 2005 8:20 pm   Post subject: Storing Times in Variables

I can't figure out how I can record a time as a variable... Say I use this to determine how long the user took to complete a maze:
code:
Time.Elapsed/1000:0:2

How would I be able to store it as a variable? When I tried doing something like:
code:
timer:=Time.Elapsed/1000:0:2

it just gave me a syntax error at ":="... Any pointers on this situation?
Sponsor
Sponsor
Sponsor
sponsor
vagyb




PostPosted: Mon Jun 20, 2005 8:24 pm   Post subject: Re: Storing Times in Variables

DarkMastermind wrote:
I can't figure out how I can record a time as a variable... Say I use this to determine how long the user took to complete a maze:
code:
Time.Elapsed/1000:0:2

How would I be able to store it as a variable? When I tried doing something like:
code:
timer:=Time.Elapsed/1000:0:2

it just gave me a syntax error at ":="... Any pointers on this situation?


um.. well try using wallclock command to record the time in how long it takes to complete, this way its much easier. search wallclock in turing help.
DarkMastermind




PostPosted: Mon Jun 20, 2005 8:26 pm   Post subject: (No subject)

Thanks, I just noticed that a second before I noticed your reply. I feel like quite the arse now Embarassed .. But now I'm stuck again, I don't know how to use it. The Turing Help description confuses me. It can only be used to count the time since 1/1/1970?

In addition, how can I take the time from when the user begins the game, excluding any time the introduction and recording of user name takes?
vagyb




PostPosted: Mon Jun 20, 2005 8:47 pm   Post subject: (No subject)

okay create t1 and t2 variables, put wallclock (t1) in begining of program and wallclock (t2) at the end of program (when u loose) then do t2-t1 and put t2, will show wat time it is Smile

var t1 : int
var t2 : int
wallclock (t1)
delay (5000)
wallclock (t2)
t2 := t2 - t1

put t2

edit: lolz i wrote c0ck by accident instead of clock and it cencsored it.
DarkMastermind




PostPosted: Mon Jun 20, 2005 8:52 pm   Post subject: (No subject)

Thanks a ton!
[Gandalf]




PostPosted: Mon Jun 20, 2005 8:55 pm   Post subject: (No subject)

Wallclock, from what I remember tells you the amount of milliseconds or seconds since 1970. To use that like Time.Elapsed you would have to do some math on it.

Why not just use Time.Elapsed, properly.
code:
var timer:=Time.Elapsed/1000
put timer


When you have timer:=Time.Elapsed/1000:0:2 you are telling it to show the declaration of the variable somewhere on the screen. That's just not possible. You have to use put for that, while you used it when declaring what the variable it.

*EDIT* grr, all that time to post and there are so many others.
Trust me though, you'll want to use the simpler method, Time.Elapsed.
MysticVegeta




PostPosted: Mon Jun 20, 2005 9:25 pm   Post subject: (No subject)

code:
var timer : real
var timerstr : string

timer := Time.Elapsed / 1000
timerstr := realstr (timer, 1)
timerstr := timerstr (1 .. index (timerstr, ".") + 2)

if index (timerstr, ".") > 0 then
    timer := strreal (timerstr)
end if

put timer
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  [ 7 Posts ]
Jump to:   


Style:  
Search: