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

Username:   Password: 
 RegisterRegister   
 Timer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
[Flame][Boy]




PostPosted: Thu Dec 15, 2005 6:46 pm   Post subject: Timer

Hey ive come up with this simple timer code but the only thing i cant figure out is why it isnt exiting at 0. Anyone know whats going on?

code:

var counter : int := 5
loop
    locate (1, 1)
    put counter - round (Time.Elapsed / 1000)
    exit when Time.Elapsed = 0
end loop
Sponsor
Sponsor
Sponsor
sponsor
Mr. T




PostPosted: Thu Dec 15, 2005 6:57 pm   Post subject: Alex's Opinion

You have to understand that Time.Elapsed is a predefined Turing command. Thus, you cannot edit by performing an operation on it. Rather, you must declare a variable and store all the operations you do to Time.Elapsed in it.
code:
var counter : int := 5
var endStatement : int
loop
    locate (1, 1)
    endStatement := counter - round (Time.Elapsed / 1000)
    put counter - round (Time.Elapsed / 1000)
    exit when endStatement = 0
end loop
ode:
Mr. T




PostPosted: Thu Dec 15, 2005 6:57 pm   Post subject: Re: Alex's Opinion

Pwned wrote:
You have to understand that Time.Elapsed is a predefined Turing command. Thus, you cannot edit it by performing an operation on it. Rather, you must declare a variable and store all the operations you do to Time.Elapsed.
code:
var counter : int := 5
var endStatement : int
loop
    locate (1, 1)
    endStatement := counter - round (Time.Elapsed / 1000)
    put counter - round (Time.Elapsed / 1000)
    exit when endStatement = 0
end loop
ode:
McKenzie




PostPosted: Thu Dec 15, 2005 6:57 pm   Post subject: (No subject)

Time.Elapsed will never be 0 but counter - round (Time.Elapsed / 1000) will be at some point
Mr. T




PostPosted: Thu Dec 15, 2005 7:00 pm   Post subject: Alex's Opinion

Sorry about the double post. Gah can someone delete the second one. Embarassed
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  [ 5 Posts ]
Jump to:   


Style:  
Search: