Author |
Message |
S_Grimm
|
Posted: Wed Apr 30, 2008 11:54 am Post subject: A better way then QUIT? |
|
|
Alright. I know that there must be a better way to exit a Turing Program than "quit", but I don't know it. Can anyone else perhaps, inform me what it is? (If I'm not crazy and a way does exist.) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Wed Apr 30, 2008 11:58 am Post subject: RE:A better way then QUIT? |
|
|
Have no more code to run. So exit your main loop such that there is no more code to run afterward. |
|
|
|
|
|
petree08
|
Posted: Wed Apr 30, 2008 12:08 pm Post subject: RE:A better way then QUIT? |
|
|
Window.Close (WinID) - F9 it |
|
|
|
|
|
Tony
|
Posted: Wed Apr 30, 2008 3:22 pm Post subject: Re: RE:A better way then QUIT? |
|
|
petree08 @ Wed Apr 30, 2008 12:08 pm wrote: Window.Close (WinID) - F9 it
that's a better way to exit the program, how? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Sean
|
Posted: Wed Apr 30, 2008 3:25 pm Post subject: RE:A better way then QUIT? |
|
|
Window.Close just closes the created window and cancles, however I doubt that is what they wanted. |
|
|
|
|
|
darkangel
|
Posted: Wed Apr 30, 2008 3:26 pm Post subject: Re: A better way then QUIT? |
|
|
also works, it stops the program dead in its tracks. |
|
|
|
|
|
Sean
|
Posted: Wed Apr 30, 2008 3:30 pm Post subject: RE:A better way then QUIT? |
|
|
Or if it is in a loop, and something happens use
|
|
|
|
|
|
syntax_error
|
Posted: Wed Apr 30, 2008 4:34 pm Post subject: RE:A better way then QUIT? |
|
|
I truly detest the teaching of exit as the only way to get out of a loop, the best way taht should be taught is meeting the condition of the loop. no? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
S_Grimm
|
Posted: Thu May 01, 2008 10:25 am Post subject: RE:A better way then QUIT? |
|
|
Sorry, I should have been more specific. The code goes something like this:
CODE
if (i = "yes") then
QUESTIONS %Procedure that has been predefined%%%
end if
if (i = "no") then
quit ************* This is the part I want to change
end if
END CODE
ther are about 2 loops ahead of this statement, and exit didn't work (i tried) |
|
|
|
|
|
Clayton
|
Posted: Thu May 01, 2008 11:17 am Post subject: Re: RE:A better way then QUIT? |
|
|
syntax_error @ Wed Apr 30, 2008 4:34 pm wrote: I truly detest the teaching of exit as the only way to get out of a loop, the best way taht should be taught is meeting the condition of the loop. no?
Ummm... Let's say you have some condition that you need to obtain in a loop for exit:
code: |
loop
exit when [condition]
end loop |
This is fine. But what if some form of computation needs to occur after that condition is true? Our code would now look like this:
code: |
loop
if [condition] then
<computation>
exit
end if
end loop |
In fact, the first code block is just syntactical sugar for:
code: |
if [condition] then
exit
end if
|
So what's the problem? |
|
|
|
|
|
petree08
|
Posted: Thu May 01, 2008 11:23 am Post subject: RE:A better way then QUIT? |
|
|
what i mean by Window.Close is that after the program is done it closes the window.
I figured he wanted to know how to get the program to close the wnidow after the program. |
|
|
|
|
|
S_Grimm
|
Posted: Thu May 01, 2008 11:40 am Post subject: RE:A better way then QUIT? |
|
|
I need to complete close the program if the answer is wrong. if it is right, the program goes on. |
|
|
|
|
|
Prince Pwn
|
Posted: Thu May 01, 2008 12:19 pm Post subject: RE:A better way then QUIT? |
|
|
I don't have Turing with me but I know what you mean. It goes something like this:
% instead of View.Set at the top of your program, do:
var winID := Window.Open("graphics;400:500")
% at the bottom
Window.Close(winID)
If you compile your program into an exe, you can check a box to "close program when finished".
I know you can get it to close somehow, I did it before. If none of that works then keep trying something like that. |
|
|
|
|
|
Sean
|
Posted: Thu May 01, 2008 2:09 pm Post subject: Re: A better way then QUIT? |
|
|
He never once ment closing a window. As said before, he needs to exit or return as one of his conditions.
If your code is in a loop, which it should be then:
Turing: |
if i = "Yes" or i = "yes" then
%Code
else
exit
end if
|
|
|
|
|
|
|
S_Grimm
|
Posted: Mon May 05, 2008 10:51 am Post subject: Re: A better way then QUIT? |
|
|
Yes it's in a loop. nestled within a loop so it's like this
code: |
loop
%More code above this
get answer
loop
if answer = "yes" or answer = "Yes then
exit
elsif answer = "no" or answer = "No" then
quit %I need to change this
elsif answer not= "Yes" or answer not= "yes" or answer not= "no" or answer not= "No" then
put "Incorect input. Please Re-Enter : "..
get answer
end loop
%more code
end loop |
My problem is the second loop, the one for the entire program. "exit" will only exit the second loop, not the first loop. I need a way to exit BOTH loops at once. |
|
|
|
|
|
|