Is is possible to set up a Mathematica notebook so that all outputs are automatically deleted when the notebook is closed? I was trying to look for some function like OnNotebookClose[]
. Any ideas?
The main reason for wanting something like this is because some of the output I have is dynamic and often gets really messy when I re-open the notebook and the output is partially undefined or unformatted.
Perhaps trickier: in the case of an unsaved notebook, when asked whether I want to save the notebook, would it still be possible to click "Cancel" without erasing the output cells? This is just to avoid accidentally clicking on the window close button
NotebookEventActions
. Also, you might want to consider doing something in theInitialization
of theDynamicModule
and similar outputs $\endgroup$