Author |
Message |
buzzkik
|
Posted: Sun Dec 09, 2007 9:50 pm Post subject: Restart Program |
|
|
Is there a way that I can restart the program in turing through a command???
If not then how can I reset the Time.Elapsed counter? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
rdrake
|
Posted: Sun Dec 09, 2007 11:35 pm Post subject: RE:Restart Program |
|
|
Why don't you just store the value of Time.Elapsed in a variable when you want to reset it, then subtract the next Time.Elapsed time from the offset? |
|
|
|
|
|
Sean
|
Posted: Mon Dec 10, 2007 12:31 pm Post subject: Re: Restart Program |
|
|
How about you show a quick example? |
|
|
|
|
|
rdrake
|
Posted: Mon Dec 10, 2007 12:52 pm Post subject: Re: Restart Program |
|
|
Turing: | % Do something long and complicated here.
put "It's been " + Time.Elapsed + " since you started this."
var offset : real := Time.Elapsed
% Do something else equally as long and complicated here.
put "It's been " + (Time.Elapsed - offset ) + " since I was \"reset\"" | May or may not compile, I don't know Turing. |
|
|
|
|
|
Clayton
|
Posted: Mon Dec 10, 2007 1:05 pm Post subject: RE:Restart Program |
|
|
Fixed code:
Turing: | %Do something long and complicated here
put "It's been ", Time.Elapsed, " since you started this."
var offset : int := Time.Elapsed
%Do something equally as long and complicated here
put "It's been ", Time.Elapsed - offset, " since I was \"reset\"" |
|
|
|
|
|
|
Sean
|
Posted: Mon Dec 10, 2007 1:28 pm Post subject: Re: Restart Program |
|
|
buzzkik @ Sun Dec 09, 2007 9:50 pm wrote: Is there a way that I can restart the program in turing through a command???
If not then how can I reset the Time.Elapsed counter?
With all the examples, none have reset the program. |
|
|
|
|
|
Nick
|
Posted: Mon Dec 10, 2007 3:17 pm Post subject: RE:Restart Program |
|
|
if you want to restarrt te program then sererate your program into a procedure and call it in a loop that does only that
Turing: | procedure game
%game code here
end game
loop
game
end loop |
|
|
|
|
|
|
buzzkik
|
Posted: Mon Dec 10, 2007 10:00 pm Post subject: Re: Restart Program |
|
|
So is there no command in turing that simply exits the program and then starts it again?
Using Procedures through loops simply gets the code in the procedure and keeps on looping it in the loop until you exit the loop somehow. It doesn't technically "exit" the actual program and then execute it again.
I tried Window.Open and Window.Close but that simply opens or closes the windows.
I'm such a noob at Turing.............. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Nick
|
Posted: Mon Dec 10, 2007 10:03 pm Post subject: RE:Restart Program |
|
|
hmm try Sys.Exec at the end to reopen the same file (however it may need to be compiled)
sample:
Turing: | if not Sys.Exec(fileName ) then
put "The file code not be opened"
end if |
|
|
|
|
|
|
Tony
|
Posted: Mon Dec 10, 2007 10:04 pm Post subject: Re: Restart Program |
|
|
buzzkik @ Mon Dec 10, 2007 10:00 pm wrote: So is there no command in turing that simply exits the program and then starts it again?
You can try to have it execute itself with Sys.Exec and then exit upon success.
Edit: momop has beat me to it, with the same solution. Good job. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Clayton
|
Posted: Mon Dec 10, 2007 10:04 pm Post subject: RE:Restart Program |
|
|
Why do you want to restart your program to begin with? If it comes to it, just have a "reset" procedure which sets all values of your variables back to default, as well as sets your Time.Elapsed offset to the current time. |
|
|
|
|
|
|