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

Username:   Password: 
 RegisterRegister   
 timing?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dphearnz




PostPosted: Fri Dec 15, 2006 11:09 am   Post subject: timing?

ok so i wanna put a little timer in the corner that can count down and then my loop will end when it gets to zero...i tried declaring an integer variable, then giving it a value, then making it a decreasing counter (by one) after a delay of 1000...it works, but the rest of the program wont execute with it. the counter goes but nothing else will go. it wont count WHILE the other stuff happens. am i doing it wrong? i just want it to count down in seconds. any ideas O'almighty masters? Very Happy
Sponsor
Sponsor
Sponsor
sponsor
ZeroPaladn




PostPosted: Fri Dec 15, 2006 12:55 pm   Post subject: (No subject)

well, there ar a few ways to help you out. The only way that i know how is to make another counter and make the other counter decrease by one when the first counter hits 1000 (for 1000 ms), throw that in a loop/for loop and use an if statement to see wheter a second has passed.
psuedo:
counter1 as integer
couner2 as integer
counter1 = 60

loop
    counter2 + 1
    if counter2 = 1000 then
        counter2 = 0
        counter1 - 1
    end if
end loop

Perhaps this will help you out, once you figure out how it works.

The second way of doing this (i think) is using the Turing function of Time.SinceLastDelay. I'm not sure how it works, but I've been told you can use this in an if statement to figure out when your counter should increment, because it determines the time since it last called itself (i think). You should probably take the advice from someone who knows how this function works, but type it out and hit F9 for the help file. Good Luck!
Clayton




PostPosted: Fri Dec 15, 2006 1:53 pm   Post subject: (No subject)

not quite Wink

look up Time.Elapsed What it does is give you the time since the beginning of the program in milliseconds. Using that, take the time when you want it to start, then take the time again at the end of a loop, if the difference between the two of them is how much time your timer needs to be, then exit or do whatever.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: