
-----------------------------------
1337 Tur1n6 5ki11z0rZ
Mon May 16, 2005 11:42 am

How can you &quot;exit on command&quot;
-----------------------------------
Im trying to make a program, and this is the one thing I really cant get.
Im wondering how to make it so that when the user pushes a character
it exits the program at ANY GIVEN TIME. (eg in the middle of pics, upcoming text, etc)

Any feedback would be appreciated.
-Thanks

 :)

-----------------------------------
Dan
Mon May 16, 2005 11:49 am


-----------------------------------
I belvie that the return comand will exit out of the progame. I am not 100% shure b/c i do not have turing at work nor do i have the turing doc here.

-----------------------------------
Delos
Mon May 16, 2005 2:30 pm


-----------------------------------
How well do you know OOT GUI?  If you look into it, there are definitely ways of doing this, though you'd be using the GUI in a pseudo- fashion, since you'd not need to make use of any of the pretty buttons or scrolls bars.  Just the fact that it all runs in a loop.  If you're interested in this method, then post up your attempt at it and I'll see if I can point you in a less confusing direction.

-----------------------------------
Notoroge
Mon May 16, 2005 2:56 pm


-----------------------------------
hint, look up "process" and "fork" in the Turing help guide.

-----------------------------------
void
Mon May 16, 2005 4:39 pm


-----------------------------------
umm...my guess...try creating a process thats made to close the window 
Window.Close ()
and then fork it with ur main process...i dunno if thats efficient tho

-----------------------------------
Notoroge
Mon May 16, 2005 4:41 pm


-----------------------------------
umm...my guess...try creating a process thats made to close the window 
Window.Close ()
and then fork it with ur main process...i dunno if thats efficient thoClose, but not really. :)

-----------------------------------
Notoroge
Mon May 16, 2005 6:12 pm


-----------------------------------
"Do?" said my attorney. "Jesus Christ man. They chopped her goddamn head off right there in the parking lot! Then they cut all kinds of holes in her and sucked out the blood!"
  "God almighty!" The Georgia man exclaimed . . . "And nobody did anything?"
  "What could they do?" I said. "The guy that took the head was about six-seven and maybe three hundred pounds. He was packing two Lugers, and the other had M-16s. They were all veterans . . ."

Hehe, I was actually reading that book when Yahoo! Messenger gave me a pop-up telling me that someone just replied in this thread. :) Nice sig.

-----------------------------------
AsianSensation
Mon May 16, 2005 9:01 pm


-----------------------------------
well, I never liked processes, so here is another solution, without using forks:

loop
    if hasch then
        return
    end if
end loop

that should work. Basicly, it checks to see whether a key has been pressed, and then the return statement will exit out of your program.

-----------------------------------
Notoroge
Mon May 16, 2005 9:04 pm


-----------------------------------
Wouldn't the program be stuck in that loop though? And I thought the whole point of it was to be able to exit the program at any given point while it was doing something else; which is the whole purpose of "forking". Or maybe I'm missing something. :eh:

-----------------------------------
AsianSensation
Mon May 16, 2005 9:16 pm


-----------------------------------
Well, I assumed his program will contain a main loop at least.

So during anywhere in his main loop, have the if hasch return statement will make him exit.

*Edit: Nvm then, he did say ANYTIME right? That would mean anytime. So process and forking is probably the only way to go. Even though I hate processes.......

You could always just do:

process GARBAGE
    loop
        if hasch then
            return
        end if
    end loop
end GARBAGE
fork GARBAGE

-----------------------------------
Notoroge
Mon May 16, 2005 9:17 pm


-----------------------------------
Which is exactly what I was implying. :P

-----------------------------------
void
Tue May 17, 2005 11:47 am


-----------------------------------
haha..amazing book..hillarious movie...yougotta watch it

-----------------------------------
1337 Tur1n6 5ki11z0rZ
Tue May 17, 2005 12:25 pm


-----------------------------------
Wow,
I got a lot of replys so quickly... I didn't expect so much advice so soon.
Thanks for all the feedback, but I left out one 'thing' in my original
post... I want to make a DESIGNATED KEY in which the user pushes to terminate the program. Not like 'hasch' that makes the program exit when ANY key is hit. Basically what I want to accomplesh is to create a DESIGNATED KEY, and when the user pushes this key the program terminates. 
For future replys please use 'e' as the designated key to exit, for that is what I am going to use in my program. 

-Thanks again  :)

-----------------------------------
Delos
Tue May 17, 2005 1:54 pm


-----------------------------------
Then instead of hasch you could use getch(), or even better Input.KeyDown().
As a last resort, you could use the quit command, but that never looks pretty...no, never at all.  (Hence my advice on using GUI, since there also exists GUI.Quit...which could theoretically work).

-----------------------------------
1337 Tur1n6 5ki11z0rZ
Wed May 18, 2005 10:44 am


-----------------------------------
Can anyone please post an example of how this works? =)

-Thanks

-----------------------------------
Lazarus
Wed May 18, 2005 12:52 pm


-----------------------------------
I don't have OOT with me but I think this should work.

 var chars : array char of boolean

loop
put "blah"

        Input.KeyDown (chars)
        if chars ('t') then
return 
end if
end loop


Press "t" to stop the program incase you didn't notice.

And the ony part of the code you really want is

        Input.KeyDown (chars)
        if chars ('t') then
you want it inside a loop or an array like I demenstrated above

-----------------------------------
StarGateSG-1
Thu May 19, 2005 7:36 am


-----------------------------------
Code: 
process GARBAGE 
    loop 
        if hasch then 
            return 
        end if 
    end loop 
end GARBAGE 
fork GARBAGE 

Just one thing I noticed, i won't help anyone but you can't use processes to wait for a key to be pressed, I tryed that with a Text bases Rpg.

-----------------------------------
1337 Tur1n6 5ki11z0rZ
Thu May 19, 2005 10:43 am


-----------------------------------
I tried:

var chars : array char of boolean 

loop 
put "blah" 

        Input.KeyDown (chars) 
        if chars ('t') then 
return 
end if 
end loop 

I was just wondering, is there anyway for this to work outside of a loop?
Because for my program I dont have too many loops, and if it was written in just one loop, wouldn't it have to be written in all the loops in order to be able to work at any given time?

Thanks again

-----------------------------------
Bacchus
Thu May 19, 2005 10:08 pm


-----------------------------------
if u put it in a process, it will run almost at the same time as your current program. that way while you main loops are running, this other loop will be running sepratly
