Re: Seperate input and output in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg16575] Re: Seperate input and output in mathematica
- From: "P.J. Hinton" <paulh>
- Date: Wed, 17 Mar 1999 23:54:54 -0500
- Organization: "Wolfram Research, Inc."
- References: <innclip7cl8ab$9e2@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 16 Mar 1999, Wenxin Mao wrote: > [ Clipped from: comp.soft-sys.math.mathematica ] > In mathematica frontend, all input and output are mixed together. > > Is there anyway to seperate input and output ? I mean in a windows I input > programs, and results show in another window. Here is a very simple implementation of what you describe using notebook manipulation functions: (* First, we define a function named externalOuptut[] that acts as a wrapper to NotebookWrite[]. *) In[1]:= externalOutput[Null]:= Return[] In[2]:= externalOutput[externalOutput] :=Return[] In[3]:= 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"]]] In[4]:= externalOutput[expr_]:= NotebookWrite[$outputNotebook,Cell[BoxData[ToBoxes[expr]], "Output"]] (* This keeps graphics from being displayed in the notebook with Input style cells. *) In[5]:= $DisplayFunction = Identity; (* To use the functions above, we create a global variable named $outputNotebook, which points to the notebook where output is to be placed. *) In[6]:= $outputNotebook= NotebookCreate[]; (* Setting $Post to use externalOutput means that all expressions returned by the kernel will be fed to the externalOutput function. *) In[7]:= $Post = externalOutput (* Here are some tests *) In[8]:= 2+2 (* Notice that graphics appear only in the external notebook *) In[9]:= Plot[Sin[x], {x,0,2Pi}] In[10]:= Plot3D[Sin[x] Cos[y], {x, 0, 2Pi}, {y, 0, 2Pi}] (* Any expression that returns Null does not create an Ouput style cell. *) In[11]:= 2+2; -- 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.