Command of some sort when terminate = true?
Author |
Message |
uberwalla
|
Posted: Mon Dec 18, 2006 6:38 pm Post subject: Command of some sort when terminate = true? |
|
|
ok so i know that if you have a program you can have it so that it runs a certain line of code when you exit the program with the end line or something. if you dont understand well here is an example of what i mean for visual people (kinda like me)
code: |
proc quit
draw....
quit
end quit
blah blah blah
put blah
get , etc.
quit
|
ok so i know i can do that if the program exits/quits through code. but is there a way to run a command due to someone quiting the program manually. example... u run the code and someone clicks the x top right corner to close. when it goes to close//terminate it runs a command in response. is that possible?
as an example to that. you terminate the program and it automatically saves a screenshot of the turing screen or something. and saves it.
thx in advance |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Mon Dec 18, 2006 6:53 pm Post subject: (No subject) |
|
|
Yes it is possible...
First though, you need to make your window a variable (sounds odd eh)
code: |
var GameWindow: int
GameWindow := Window.Open("Graphics:max;max")
proc endWindow
Window.Close(GameWindow)
end endWindow
put "this is a test"
put "press a key for termanation"
Input.Pause
endWindow
|
Is that what you are looking for? |
|
|
|
|
|
Cervantes
|
Posted: Mon Dec 18, 2006 7:11 pm Post subject: (No subject) |
|
|
Actually, the correct answer is, "No".
When you click the x on the window, the program is halted. What's really happening is a signal is being sent from the window manager to Turing to tell it to die. In response, Turing pops up a little window with a yes/no dialogue. Unfortunately, there are no commands to interact with this kill signal. That's taken care of on a level above the code you wrote.
As for the example code you posted, it's got problems. First, quit is a predefied keyword, so you can't name a procedure "quit". Second, even if the keyword quit didn't exist and your code didn't have any syntax errors, you'd "put blah", then call quit, which would draw something, then call quit, which would draw something, then call quit, which would draw something, then call quit.... forever. Your program would never quit because of this recursion. |
|
|
|
|
|
uberwalla
|
Posted: Mon Dec 18, 2006 7:18 pm Post subject: (No subject) |
|
|
lol i know my code was wrong i was just saying blahs as in other code and stuff. i was just putting that more of what i dont want to do.
Quote:
First though, you need to make your window a variable (sounds odd eh)
thx for help but its not that odd i know about that but what i was trying to do is that it shuts down when user hits x and as cervantes said wasnt possible.
thx for help guys |
|
|
|
|
|
|
|