Re: How to: Read Notebook and auto-evaluate ?
- To: mathgroup at smc.vnet.net
- Subject: [mg20993] Re: How to: Read Notebook and auto-evaluate ?
- From: paulh at wolfram.com (P.J. Hinton)
- Date: Thu, 2 Dec 1999 21:41:08 -0500 (EST)
- Organization: "Wolfram Research, Inc."
- References: <firstname.lastname@example.org>
- Sender: owner-wri-mathgroup at wolfram.com
In article <822gff$7fe at smc.vnet.net>, pecora at zoltar.nrl.navy.mil (Lou Pecora) writes: >I am unsuccessful in reading in a Notebook and automatically evaluating >its cells. The Mathematica book makes it sound simple, but it doesn't >work. What am I doing wrong? > >E.g. I have a notebook ("mynbook.nb", say) with one line: > >xx=2; > >This is a normal cell. Then when running a session in another notebook I >use Get to read it in: > >Get["mynbook.nb"] > >This returns lines of text about notebook stuff and shows the assignment >xx=2 in the midst of all that. But when I type > >xx (enter) > >I just get xx back, not 2. Looks like Mathematica finds the Notebook but >does not evaluate the cells. How can I do this? Thanks for any help. Your Get operation reads in the Mathematica expression corresponding to the notebook document itself. It does not evaluate the cells therein. You can use the autogenerate package feature of the front end to save out Input style cells in a companion package file (e.g. mynotebook.m) that contains evaluatable forms. I have posted some articles in this newsgroup in the past describing step-by-step how to do this. You can retrieve one of the archived postings at Deja.com. http://x33.deja.com/getdoc.xp?AN=382536762 Note that the name of the notebook option InitializationCellLoading has been changed to InitializationCellEvaluation for Mathematica 4. Documentation for this option can be found in the online help by evaluating this expression in a notebook. FrontEndExecute[ FrontEnd`HelpBrowserLookup[ "OtherInformation", "InitializationCellEvaluation" ] ] -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc. Disclaimer: Opinions expressed herein are those of the author alone.