Much as latent expressions now are executed when a workspace is opened, I think it would be useful also to have latent-like expressions that are executed when a workspace is closed. One application of such a latent expression could be to expunge any printer object that happened to remain open when the workspace was closed.
Would anyone else find this proposed extension to Dyalog useful?
Suggestion of a latent expression for workspace closure
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
- Dick Bowman
- Posts: 235
- Joined: Thu Jun 18, 2009 4:55 pm
- Contact:
Re: Suggestion of a latent expression for workspace closure
I think that this could/would be properly done by your application code. The point of ⎕LX being to force some application code to run when the interpreter has just started and has nothing to do - ⎕LX gives it that something. But once you've started, then you're in control.
Of course, I write this from a context of domineering applications. There might be a case where your workspace is just sitting there waiting for you to interact with it.
But personally, I don't think I've ever felt the need...
Of course, I write this from a context of domineering applications. There might be a case where your workspace is just sitting there waiting for you to interact with it.
But personally, I don't think I've ever felt the need...
Visit http://apl.dickbowman.com to read more from Dick Bowman
-
- Posts: 431
- Joined: Fri Oct 03, 2008 4:14 pm
Re: Suggestion of a latent expression for workspace closure
Isn't this better accomplished with a simple Off function that does what you want and then does a quadOFf at the end? ? As Dick notes, the reason for quadLX is that you want something to happen automatically. You have to take action as it is to close a session, so why not do Off instead of )Off.
Re: Suggestion of a latent expression for workspace closure
But there are numerous ways that a workspace can be closed other than by typing ')OFF'. They include loading another workspace, closing the session window, etc. My proposed latent-expression-at-workspace-closure would be invoked in all such circumstances.
-
- Posts: 439
- Joined: Wed Oct 01, 2008 9:39 am
Re: Suggestion of a latent expression for workspace closure
Hi MichaelK,
Just to let you know, we do expunge your GUI objects such as printer objects when you )clear or load another workspace or Exit the interpreter.
JD has said to me that you can achieve some of what you are asking for with classes, event callbacks, and a destructor method.
Here is what I've come up with:
)cs ⎕SE
Start editing a new class:
)ed ○wsdestro
Paste the following into the editor and save it.
Add the following initialization function call to the WorkspaceLoaded event callback.
)ed ⎕SE.Dyalog.Callbacks.WSLoaded
⎕SE.wsclosingmsg←⎕NEW ⎕SE.wsdestro
Save the session file.
Regards,
Vince
Just to let you know, we do expunge your GUI objects such as printer objects when you )clear or load another workspace or Exit the interpreter.
JD has said to me that you can achieve some of what you are asking for with classes, event callbacks, and a destructor method.
Here is what I've come up with:
)cs ⎕SE
Start editing a new class:
)ed ○wsdestro
Paste the following into the editor and save it.
Code: Select all
:Class wsdestro
∇ closing
:Implements Destructor
'm'⎕WC'msgbox' 'Closing...'
⎕DQ'm'
∇
:EndClass
Add the following initialization function call to the WorkspaceLoaded event callback.
)ed ⎕SE.Dyalog.Callbacks.WSLoaded
⎕SE.wsclosingmsg←⎕NEW ⎕SE.wsdestro
Save the session file.
Regards,
Vince