tags:

views:

50

answers:

2

How to trigger close event for Rebol Console to execute some custom handler before one quit the console ?

+1  A: 

Well, I don't understand why you need this. If you're running a script from the console, then surely your script "knows" when it is about to quit.

Maybe you're after a system shutdown or similar? In that case you need to look at the system ports.

See http://www.rebol.org/ml-display-thread.r?m=rmlNFFJ

for an example of trapping the shutdown event for different OSes.

Graham Chiu
I don't want to know when my script quit. I am in Reb console no script is running, I want to know when user close the console window. It's like in browser there is an event that is triggered when a user close a window.
Rebol Tutorial
Your article is interesting but I don't even want to trigger OS i just want to trigger rebol console system :)
Rebol Tutorial
+1  A: 

AFAIK REBOL doesn't offer a hook for that. And if you wanted to do it with a system port hook, you would have to have an event loop running.

If you have behavior you want to trigger, the first thing I would do is add a simple SHUTDOWN mezzanine, to replace QUIT, and do your work there. You could view that as a feature or a limitation, meaning the user can avoid your logic by using the close button if they want.

Gregg Irwin
I cannot add quit since the console is the ONLY user interface. So I cannot add any quit button. Adding such hooks feature is a real value to rebol much more than pure syntax stuff. I was hoping rebol 3 would be more targeted at such things that is toolings.
Rebol Tutorial
Don't think the console was ever meant to be a user interface. Need a View-based console...
rgchris
It's not too late to think :) Don't think that console is just for stupid users. In most well-known business application like SAP users use command line. Google is being now launching google-cl so for sure console can also be for users who want to do things faster without using cryptic batch file.
Rebol Tutorial