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

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




PostPosted: 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
Sponsor
sponsor
rdrake




PostPosted: 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




PostPosted: Mon Dec 10, 2007 12:31 pm   Post subject: Re: Restart Program

How about you show a quick example?
rdrake




PostPosted: 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




PostPosted: 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




PostPosted: 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. Shocked Burn
Nick




PostPosted: 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




PostPosted: 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? Confused

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.............. BooHoo
Sponsor
Sponsor
Sponsor
sponsor
Nick




PostPosted: 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




PostPosted: 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? Confused

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Clayton




PostPosted: 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.
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  [ 11 Posts ]
Jump to:   


Style:  
Search: