Computer Science Canada How can you "exit on command" |
Author: | 1337 Tur1n6 5ki11z0rZ [ Mon May 16, 2005 11:42 am ] |
Post subject: | How can you "exit on command" |
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 ![]() |
Author: | Dan [ Mon May 16, 2005 11:49 am ] |
Post subject: | |
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. |
Author: | Delos [ Mon May 16, 2005 2:30 pm ] |
Post subject: | |
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. |
Author: | Notoroge [ Mon May 16, 2005 2:56 pm ] |
Post subject: | |
hint, look up "process" and "fork" in the Turing help guide. |
Author: | void [ Mon May 16, 2005 4:39 pm ] |
Post subject: | |
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 |
Author: | Notoroge [ Mon May 16, 2005 4:41 pm ] |
Post subject: | |
void wrote: umm...my guess...try creating a process thats made to close the window
Close, but not really. Window.Close () and then fork it with ur main process...i dunno if thats efficient tho ![]() |
Author: | Notoroge [ Mon May 16, 2005 6:12 pm ] |
Post subject: | |
"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. ![]() |
Author: | AsianSensation [ Mon May 16, 2005 9:01 pm ] | ||
Post subject: | |||
well, I never liked processes, so here is another solution, without using forks:
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. |
Author: | Notoroge [ Mon May 16, 2005 9:04 pm ] |
Post subject: | |
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. ![]() |
Author: | AsianSensation [ Mon May 16, 2005 9:16 pm ] | ||
Post subject: | |||
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:
|
Author: | Notoroge [ Mon May 16, 2005 9:17 pm ] |
Post subject: | |
Which is exactly what I was implying. ![]() |
Author: | void [ Tue May 17, 2005 11:47 am ] |
Post subject: | |
haha..amazing book..hillarious movie...yougotta watch it |
Author: | 1337 Tur1n6 5ki11z0rZ [ Tue May 17, 2005 12:25 pm ] |
Post subject: | |
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 ![]() |
Author: | Delos [ Tue May 17, 2005 1:54 pm ] |
Post subject: | |
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). |
Author: | 1337 Tur1n6 5ki11z0rZ [ Wed May 18, 2005 10:44 am ] |
Post subject: | |
Can anyone please post an example of how this works? =) -Thanks |
Author: | Lazarus [ Wed May 18, 2005 12:52 pm ] | ||||
Post subject: | |||||
I don't have OOT with me but I think this should work.
Press "t" to stop the program incase you didn't notice. And the ony part of the code you really want is
you want it inside a loop or an array like I demenstrated above |
Author: | StarGateSG-1 [ Thu May 19, 2005 7:36 am ] |
Post subject: | |
Quote: 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. |
Author: | 1337 Tur1n6 5ki11z0rZ [ Thu May 19, 2005 10:43 am ] |
Post subject: | |
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 |
Author: | Bacchus [ Thu May 19, 2005 10:08 pm ] |
Post subject: | |
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 |