Author |
Message |
1337 Tur1n6 5ki11z0rZ
|
Posted: 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
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Mon May 16, 2005 11:49 am Post subject: (No 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. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Delos
|
Posted: Mon May 16, 2005 2:30 pm Post subject: (No 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. |
|
|
|
|
|
Notoroge
|
Posted: Mon May 16, 2005 2:56 pm Post subject: (No subject) |
|
|
hint, look up "process" and "fork" in the Turing help guide. |
|
|
|
|
|
void
|
Posted: Mon May 16, 2005 4:39 pm Post subject: (No 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 |
|
|
|
|
|
Notoroge
|
Posted: Mon May 16, 2005 4:41 pm Post subject: (No subject) |
|
|
void wrote: 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 Close, but not really. |
|
|
|
|
|
Notoroge
|
Posted: Mon May 16, 2005 6:12 pm Post subject: (No 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. Nice sig. |
|
|
|
|
|
AsianSensation
|
Posted: Mon May 16, 2005 9:01 pm Post subject: (No subject) |
|
|
well, I never liked processes, so here is another solution, without using forks:
code: | 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. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Notoroge
|
Posted: Mon May 16, 2005 9:04 pm Post subject: (No 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. |
|
|
|
|
|
AsianSensation
|
Posted: Mon May 16, 2005 9:16 pm Post subject: (No 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:
code: | process GARBAGE
loop
if hasch then
return
end if
end loop
end GARBAGE
fork GARBAGE |
|
|
|
|
|
|
Notoroge
|
Posted: Mon May 16, 2005 9:17 pm Post subject: (No subject) |
|
|
Which is exactly what I was implying. |
|
|
|
|
|
void
|
Posted: Tue May 17, 2005 11:47 am Post subject: (No subject) |
|
|
haha..amazing book..hillarious movie...yougotta watch it |
|
|
|
|
|
1337 Tur1n6 5ki11z0rZ
|
Posted: Tue May 17, 2005 12:25 pm Post subject: (No 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 |
|
|
|
|
|
Delos
|
Posted: Tue May 17, 2005 1:54 pm Post subject: (No 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). |
|
|
|
|
|
1337 Tur1n6 5ki11z0rZ
|
Posted: Wed May 18, 2005 10:44 am Post subject: (No subject) |
|
|
Can anyone please post an example of how this works? =)
-Thanks |
|
|
|
|
|
|