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

Username:   Password: 
 RegisterRegister   
 how to end a program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
musicman




PostPosted: Mon May 03, 2010 11:56 am   Post subject: how to end a program

procedure battle
enemychoose
loop
put "What do you wish to do?"
put "Fight?"
put "Heal?"
put "Flee?"
get answer
if answer = "fight" then
put "Which weapon would you like to use?"
put primaryname, "?"
put secondaryname, "?"
put meleename, "?"
elsif answer = "heal" then
health := health + healRate
elsif answer = "flee" then
else
put "Invalid response"
end if
end loop
end battle



rpg - Copy.txt
 Description:
this file is a txt document you have to change it to a .t file to run it in turing or copy and paste the text

Download
 Filename:  rpg - Copy.txt
 Filesize:  12.15 KB
 Downloaded:  107 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
USEC_OFFICER




PostPosted: Mon May 03, 2010 12:03 pm   Post subject: RE:how to end a program

What are you trying to do?
Zren




PostPosted: Mon May 03, 2010 12:13 pm   Post subject: Re: how to end a program

If your wondering how to exit loops.

Turing:

loop
    exit
end loop

var running :boolean := true
loop
    exit when running = false
end loop


First one will exit straightaway while the second will cause an infinite loop without modifying the variable running inside the loop.

Oh and from now on please wrap your code in:
code:
[syntax="turing"][/syntax]

Makes things easier to see and allows for indentation to show.
musicman




PostPosted: Mon May 03, 2010 9:52 pm   Post subject: Re: how to end a program

gdi...there was suppossed to be more to that post. i know how to exit loops, what i wanted to know is how to exit a program altogether even if it is in the middle of it, for instances such as deaths in games.
TheGuardian001




PostPosted: Mon May 03, 2010 10:31 pm   Post subject: Re: how to end a program

well, that depends on how your program is structured.

If you're using loops, then you can just exit out of all your loops, such that the program reaches the end of the file.

If your game is within a procedure, you can use return to get out of that procedure, which will allow you to reach the end of the file.

Or, if you just want something that will stop the program dead in its tracks, you can use quit, which simply kills the execution of the program altogether.
musicman




PostPosted: Tue May 04, 2010 8:25 am   Post subject: Re: how to end a program

i was just looking for a command to kill the program altogether, so the quit command is the one im lookin for, thanks
BigBear




PostPosted: Tue May 04, 2010 3:13 pm   Post subject: RE:how to end a program

quit is basically used like an assert statement it is for development purposes.

your program ends when it runs out of code so it starts at the first line and goes through your code will it gets to the bottom last line.

if you have a loop it will go back to the top of that loop forever unless you exit the loop so to end you exit all loops procedures etc
TheGuardian001




PostPosted: Tue May 04, 2010 3:49 pm   Post subject: Re: how to end a program

It may be intended for debug purposes, but it will stop the program, even in compiled form. Of course, it brings up an error message, but it does kill the program.

I suppose I should mention that it is by no means the correct way to end a program. The correct way is to return out of whatever procedure you are in and exit any loops until you reach the end of your code.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: