Computer Science Canada

Time

Author:  D_homes [ Mon Nov 16, 2009 9:05 pm ]
Post subject:  Time

What is it you are trying to achieve?
Create a downward counting timer according to what the user has entered. The int needs to be changed into a string aswell for Font.Draw

What is the problem you are having?
Can't seem to get it to work. If its in the main loop, the program waits for it to count down to zero then starts. If its in a separate process, the program waits for it to get to zero, starts and the timer goes into negative numbers


What I have tried to solve this problem

Turing:

get time_remaining

for i:1..time_remaining
delay (1000)                                                                % Delays 1 second
time_remaining -= 1                                                     % Subtracts 1 from the time
time_remaining_display := intstr (time_remaining)          % Converts it to a string for Font.Draw
end for


I've also tried the for loop in a process and forked it, but it still doesn't work.


Please specify what version of Turing you are using
4.1

Author:  Tony [ Mon Nov 16, 2009 9:16 pm ]
Post subject:  Re: Time

D_homes @ Mon Nov 16, 2009 9:05 pm wrote:
I've also tried the for loop in a process and forked it, but it still doesn't work.

Did you just try to throw some random code at the problem, without understanding what it does, in hopes that it might somehow solve the problem?

Also, your loop doesn't appear to have any sort of output (any sort of put, draw, etc.)

Author:  D_homes [ Mon Nov 16, 2009 9:22 pm ]
Post subject:  Re: Time

So you're saying that the font.draw needs to be in the loop?
Makes sense don't know why i didn't f**king think of that.

Author:  B-Man 31 [ Mon Nov 16, 2009 9:36 pm ]
Post subject:  Re: Time

also instead of:

Turing:

time_remaining_display := intstr (time_remaining)


to covert it into string, you can just do this in your font.draw:

Turing:

Font.Draw (intstr (time_remaining),100,100, font,black)
%Just added some random stuff to complete the Font.Draw


This saves you a line of coding.


: