Computer Science Canada Need help with adding a timer |
Author: | animeanime [ Fri May 29, 2009 9:13 am ] | ||
Post subject: | Need help with adding a timer | ||
What is it you are trying to achieve? I want my program to have a timer What is the problem you are having? Cant add the timer Describe what you have tried to solve this problem I tried using the Tuting Help, and different methods to add a timer. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.0.3 |
Author: | Zren [ Fri May 29, 2009 10:23 am ] |
Post subject: | Re: Need help with adding a timer |
The function your looking for is: Time.Elapsed startTime = Time.Elapsed ....code... currentTime = Time.Elapsed timeSinceStart = currentTime - startTime I'm guessing your trying to do a Who Wants to be a Millionaire thing. Just make sure you reset the starting time for each question and that the value for Time.Elapsed is in milliseconds. |
Author: | animeanime [ Fri May 29, 2009 5:53 pm ] |
Post subject: | RE:Need help with adding a timer |
Ok, but I stated this var startTime: real var currentTime: real var timeSinceStart: real are they soppose to be real? And It figured out its in milliseconds. I did this startTime:= Time.Elapsed .. THE CODE .. currentTime:= Time.Elapsed timeSinceStart:= (currentTime - startTime)*1000 But the output I got was weird. Something like this: 9.289e6 How come I get some letter in between? |
Author: | tjmoore1993 [ Fri May 29, 2009 7:06 pm ] |
Post subject: | RE:Need help with adding a timer |
When a letter is given within a number for example 'e', you should know that you have hit the maximum integer value supported in Turing. Correct me if I am wrong. The best way to stop that is to check your math to see if all is correct. Also setting limits. By the way I couldn't help you in class today because it would have been cheating. |
Author: | animeanime [ Fri May 29, 2009 7:09 pm ] | ||
Post subject: | Re: Need help with adding a timer | ||
This is what I have, did I do anything wrong?
|
Author: | yumrum [ Fri May 29, 2009 7:11 pm ] |
Post subject: | RE:Need help with adding a timer |
u don't need the else point := point + 0 |
Author: | animeanime [ Fri May 29, 2009 7:12 pm ] |
Post subject: | RE:Need help with adding a timer |
so if I take that off all of them, it should fix the timer? |
Author: | tjmoore1993 [ Fri May 29, 2009 7:13 pm ] |
Post subject: | RE:Need help with adding a timer |
You did nothing wrong but you should work on efficiency. The teacher doesn't teach efficiency all that greatly... You should attempt on getting a clean system. I recommend though converting miliseconds to seconds. |
Author: | animeanime [ Fri May 29, 2009 7:14 pm ] |
Post subject: | RE:Need help with adding a timer |
I tried adding a *1000 and making it like this currentTime:= Time.Elapsed timeSinceStart:= (currentTime - startTime) *1000 I still got the " e " |
Author: | tjmoore1993 [ Fri May 29, 2009 7:17 pm ] |
Post subject: | RE:Need help with adding a timer |
Let me examine the problem, also you should not be discussing your summative on this page because the teacher will be looking. ![]() Found the error, your math is off. You do not multiply when you do miliseconds to seconds.... |
Author: | tjmoore1993 [ Fri May 29, 2009 7:24 pm ] | ||
Post subject: | RE:Need help with adding a timer | ||
|
Author: | corriep [ Fri May 29, 2009 7:49 pm ] |
Post subject: | RE:Need help with adding a timer |
Quick tip: Press F2 -> Your life just got easier |
Author: | animeanime [ Fri May 29, 2009 8:00 pm ] |
Post subject: | RE:Need help with adding a timer |
Thanks you both guys. It worked ^_^ |
Author: | animeanime [ Mon Jun 01, 2009 8:19 am ] |
Post subject: | RE:Need help with adding a timer |
Ok, I want it to output the time in minutes. But it doesent work. I put this timeSinceStart := (currentTime - startTime) / (1000) * (1000) div (1) / (1000) and tried this timeSinceStart := (currentTime - startTime) / 10000 dident work, I also timed for 1 minute, and I got like 0.6 minutes or like 0.06 minutes. what am I doing wrong? |
Author: | DemonWasp [ Mon Jun 01, 2009 10:05 am ] | ||
Post subject: | RE:Need help with adding a timer | ||
Time.Elapsed gives you times in milliseconds. A difference between two times measured with Time.Elapsed will be in milliseconds.
|
Author: | Dusk Eagle [ Mon Jun 01, 2009 3:48 pm ] |
Post subject: | Re: Need help with adding a timer |
Your code would be so much better if you used procedures along with a bit of File I/O. Not only would you save yourself a ton of work, but you would learn actual programming skills by using these techniques. |
Author: | animeanime [ Mon Jun 01, 2009 7:39 pm ] | ||||
Post subject: | Re: RE:Need help with adding a timer | ||||
DemonWasp @ Mon Jun 01, 2009 10:05 am wrote: Time.Elapsed gives you times in milliseconds.
A difference between two times measured with Time.Elapsed will be in milliseconds.
so this would be my code?
and that will give me minutes? |