Re: importing nb files
- To: mathgroup at smc.vnet.net
- Subject: [mg86708] Re: importing nb files
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Wed, 19 Mar 2008 05:23:44 -0500 (EST)
- References: <fro3a6$i8l$1@smc.vnet.net>
alexxx.magni at gmail.com wrote: > a very basic question - sorry for that... > > probably it's me, almost never having programmed large projects that > needed breaking up in different notebooks, so I seldom used the Get > (<<) function, but I seemed to remember this function would allow me > to Import&evaluate a notebook in another. > > So, defining simply a=2 in a notebook test.nb, when I executed: > > <<"test.nb" > > I obtained: > > Notebook[{Cell[ > CellGroupData[{Cell[BoxData[RowBox[{"a", "=", "2"}]], "Input", > CellChangeTimes -> {{3.41474*10^9, 3.41474*10^9}}], > Cell[BoxData["2"], "Output", CellChangeTimes -> {3.41474*10^9}]}, > Open]]}, WindowSize -> {640, 750}, > WindowMargins -> {{150, Automatic}, {Automatic, 52}}, > FrontEndVersion -> "6.0 for Linux x86 (32-bit) (February 7, 2008)", > StyleDefinitions -> "Default.nb"] > > (a verbose output which I didnt remember) and, moreover, my "a" > variable still remains undefined! > What I'm missing (or forgetting)? > > thanks! > > Alessandro > You are forgetting that Get reads .m files (sometimes known as package files), not notebooks. However, in 6.0 .m files can be edited almost as if they were notebooks and non-code information such as headings is stored in the .m file as comments. Note also, that if you open a notebook and evaluate it, and then open another and evaluate that also, the second evaluation will use any relevant definitions from the first one. David Bailey http://www.dbaileyconsultancy.co.uk