
-----------------------------------
S_Grimm
Wed Apr 30, 2008 11:54 am

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.)

-----------------------------------
Clayton
Wed Apr 30, 2008 11:58 am

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
Wed Apr 30, 2008 12:08 pm

RE:A better way then QUIT?
-----------------------------------
Window.Close (WinID) - F9 it

-----------------------------------
Tony
Wed Apr 30, 2008 3:22 pm

Re: RE:A better way then QUIT?
-----------------------------------
Window.Close (WinID) - F9 it
that's a better way to exit the program, how?

-----------------------------------
Sean
Wed Apr 30, 2008 3:25 pm

RE:A better way then QUIT?
-----------------------------------
Window.Close just closes the created window and cancles, however I doubt that is what they wanted.

-----------------------------------
darkangel
Wed Apr 30, 2008 3:26 pm

Re: A better way then QUIT?
-----------------------------------
return
also works, it stops the program dead in its tracks.

-----------------------------------
Sean
Wed Apr 30, 2008 3:30 pm

RE:A better way then QUIT?
-----------------------------------
Or if it is in a loop, and something happens use


exit


-----------------------------------
syntax_error
Wed Apr 30, 2008 4:34 pm

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?

-----------------------------------
S_Grimm
Thu May 01, 2008 10:25 am

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
Thu May 01, 2008 11:17 am

Re: 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?

Ummm... Let's say you have some condition that you need to obtain in a loop for exit:


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:


loop
    if [condition] then
        
        exit
    end if
end loop

In fact, the first code block is just syntactical sugar for:

if [condition] then
    exit
end if


So what's the problem?

-----------------------------------
petree08
Thu May 01, 2008 11:23 am

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
Thu May 01, 2008 11:40 am

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
Thu May 01, 2008 12:19 pm

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
Thu May 01, 2008 2:09 pm

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:



if i = "Yes" or i = "yes" then
     %Code
else
     exit
end if


-----------------------------------
S_Grimm
Mon May 05, 2008 10:51 am

Re: A better way then QUIT?
-----------------------------------
Yes it's in a loop. nestled within a loop so it's like this

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.

-----------------------------------
petree08
Mon May 05, 2008 11:08 am

RE:A better way then QUIT?
-----------------------------------

var Quit : boolean
loop 
%More code above this 
    get answer 
loop 
if answer = "yes" or answer = "Yes then 
Quit := true
exit 
    
elsif answer = "no" or answer = "No" then 

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 
exit when Quit 
end loop



I can't believe you had to ask that

-----------------------------------
Carey
Mon May 05, 2008 1:26 pm

RE:A better way then QUIT?
-----------------------------------
or you could just use return. return is usually used to get out of a procedure. if you call it when you are not in the middle of a procedure, it ends the program. If you have any questions PM me.

-----------------------------------
S_Grimm
Fri May 09, 2008 11:50 am

RE:A better way then QUIT?
-----------------------------------
thanks everyone
