MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: importing nb files

alexxx.magni at 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

  • Prev by Date: Re: Compiled function slowdown
  • Next by Date: Re: Compiled function slowdown
  • Previous by thread: Re: importing nb files
  • Next by thread: Bug: symbol recreates itself suddenly