Author |
Message |
musicman
|
Posted: 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
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 |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
rpg - Copy.txt |
Filesize: |
12.15 KB |
Downloaded: |
107 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
USEC_OFFICER
![](http://compsci.ca/v3/uploads/user_avatars/16624966004bb548179e82e.png)
|
Posted: Mon May 03, 2010 12:03 pm Post subject: RE:how to end a program |
|
|
What are you trying to do?
|
|
|
|
|
![](images/spacer.gif) |
Zren
![](http://compsci.ca/v3/uploads/user_avatars/1110053965512db6185954b.png)
|
Posted: 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.
|
|
|
|
|
![](images/spacer.gif) |
musicman
|
Posted: 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.
|
|
|
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: 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.
|
|
|
|
|
![](images/spacer.gif) |
musicman
|
Posted: 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
|
|
|
|
|
![](images/spacer.gif) |
BigBear
|
Posted: 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
|
|
|
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: 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.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
|