correction to externalOutput[] function
- To: mathgroup at smc.vnet.net
- Subject: [mg16650] correction to externalOutput[] function
- From: paulh (P.J. Hinton)
- Date: Fri, 19 Mar 1999 12:54:02 -0500
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
In article <7cnlr6$e7n at smc.vnet.net>, I included some sample code
that allowed a user to redirect Output style cells to a separate
notebook. The code was not as well polished as it could have been,
and I'd like to provide a note that fixes some of the shortcomings
The definition in In[3] read:
externalOutput[
expr:(_Graphics|_Graphics3D|_SurfaceGraphics|_ContourGraphics|
_DensityGraphics)]:=
Module[{$DisplayFunction = Identity},
NotebookWrite[$outputNotebook,
Cell[GraphicsData["PostScript", DisplayString[expr]], "Graphics"]];
NotebookWrite[$outputNotebook, Cell[BoxData[ToBoxes[expr]],"Output"]]
The use of the Module[] scoping construct is superfluous here and is
a remnant of some intermediate work that should have been cleaned up.
Since the left hand side of this rule matches for various graphics
objects, setting $DisplayFunction will not help here. Functions which
result in the display of graphics objects (e.g. Plot[], Plot3D[], etc.)
will have already invoked the display function by the time thiis rule
fires. Even if that weren't the case, Block[] should have been used
instead.
You can rewrite the right hand side of the rule as a compound expression.
externalOutput[
expr:(_Graphics|_Graphics3D|_SurfaceGraphics|_ContourGraphics|
_DensityGraphics)]:=
(NotebookWrite[$outputNotebook,
Cell[GraphicsData["PostScript", DisplayString[expr]], "Graphics"]];
NotebookWrite[$outputNotebook, Cell[BoxData[ToBoxes[expr]],"Output"]])
--
P.J. Hinton
Mathematica Programming Group paulh at wolfram.com
Wolfram Research, Inc. http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.
--
P.J. Hinton
Mathematica Programming Group paulh at wolfram.com
Wolfram Research, Inc. http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.