Re: Notional NotebookOpen Nonplus?
- To: mathgroup at smc.vnet.net
- Subject: [mg22305] Re: Notional NotebookOpen Nonplus?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Thu, 24 Feb 2000 03:01:20 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <88vu1s$mcl@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
The ">>" command does not write output in the special form that constitutes a notebook expression; rather, it simply writes to a text file -- no matter what extension (such as your .nb) that you give to the file. To write expressions to what will be understood by the Mathematica front end as a notebook, you have to use the various Notebook* functions. For example, the five expression indicated below, when evaluated, will: (1) create a new, open blank notebook and shift the focus to that notebook; (2) after you go back to your original notebook in which you evaluated that first expression, write into the new notebook the input cell Expand[(a+b)^3] -- NOT the result of evaluating that expression; (3) write into the new notebok cell the output that results from evaluating the expression Expand[(a+b)^3]; (4) save the new notebook as a file; and (5) close the newly-saved notebook. Here are the expressions. Expressions (2) and (3) were obtained by actually entering Expand[(a+b)^3] in an input cell in the work notebook (not the one being created) and evaluating it; then the CELL EXRPESSIONS for the input and output cells were obtained by using the menu command Format > Show Expression (or, on the Mac, the equivalent SHIFT-COMMAND-E shortcut key) for each of those two cells to display them in their cell expressions; finally, those expressions were copied and pasted into the NotebookWrite cells. There are fancier -- and probably simpler -- ways to do this, but the steps I'm showing are for the purpose of showing what's really going on. Here are the expressions: (1) mynb = NotebookCreate[] (2) NotebookWrite[mynb, {Cell[ BoxData[RowBox[{"Expand", "[", RowBox[{RowBox[{"(", RowBox[{"a", "+", "b"}], ")"}], "^", "3"}], "]"}]], "Input"]}] (3) NotebookWrite[mynb, {Cell[ BoxData[RowBox[{SuperscriptBox["a", "3"], "+", RowBox[{"3", " ", SuperscriptBox["a", "2"], " ", "b"}], "+", RowBox[{"3", " ", "a", " ", SuperscriptBox["b", "2"]}], "+", SuperscriptBox["b", "3"]}]], "Output"]}] (4) NotebookSave[mynb, "sample.nb"] (5) NotebookClose[mynb] James Fuite and Tania Nordli wrote: > > Dear Advanced Mathematica Users, > > I am not able to use the function NotebookOpen in Version 3. on > MacOS 8.1, and after modest investigations, I have to turn to you for > advice. What follows is an example. > > Expand[(a+b)^3] >> "sample.nb" > NotebookOpen["sample.nb"] > > $Failed > > !!sample.nb > > a^3 + 3*a^2*b + 3*a*b^2 +b^3 > > So I can look at the file, just not open it. Yet, further probes > indicate, at least to me, that everything is in order. > > Directory[] > > Macintosh HD:Mathematica 3.0 Files > > MemberQ[FileNames[],"sample.nb"] > > True > > ToFileName /@ (NotebookPath /. Options[$FrontEnd, NotebookPath]) > > {Macintosh HD:System Folder: > Preferences:Mathematica:3.0:FrondEnd:Palettes:, > etc., > :$HomeDirectory:, :$TopDirectory:} > > $TopDirectory > > Macintosh HD:Mathematica 3.0 Files > > It seems to me that the notebook "sample.nb" should be found and > opened. Suggestions? > > Sincerely, > James J. Fuite. -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. phone 413 549-1020 (H) Univ. of Massachusetts 413 545-2859 (W) Amherst, MA 01003-4515