RE: The difference between Needs[ ] & Get[ ]

*To*: mathgroup at smc.vnet.net*Subject*: [mg40150] RE: [mg40149] The difference between Needs[ ] & Get[ ]*From*: "David Park" <djmp at earthlink.net>*Date*: Sun, 23 Mar 2003 04:12:09 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

neuron, The reason that ComplexMap1 does not load is that Roman has not set it up as a package that can load. You can only look at it as a text file to see what an early version of the package looked like. That is because he has the Begin statement: BeginPackage["ProgrammingInMathematica`ComplexMap`"] and it should be BeginPackage["ProgrammingInMathematica`ComplexMap1`"] to be correct for loading. "ProgrammingInMathematica" gives the folder name and "ComplexMap1" would give the specific file name. He intends that you actually use the ComplexMap package. (You could also use Graphics`ComplexMap`.) The advantage of the Needs statement over Get is that it can be reevaluated and if the package is already loaded it will do nothing. Many packages cannot be loaded a second time without generating error messages. It is generally more convenient to use Needs. For example, if you open two different notebooks that both use the same package and both have initialization cells to load the package, the package will only be loaded once. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: neuron [mailto:b90401114 at ntu.edu.tw] To: mathgroup at smc.vnet.net Hello MathGroup gurus, I am new to Mathematica and now reading "Programming In Mathematica." I am a little confused with Needs[ ] & Get[ ]. I kow that Needs[ ] checks $Packages whether the package is present or not and I usually use Needs[ ] to load a package. On the xiv page of "ProgrammingInMathematica" it says "Even better is Needs["ProgrammingInmathematica`Package`"]........" but on page 13, when I input Needs["ProgrammingInMathematica`ComplexMap1`"] instead of <<ProgrammingInMathematica`ComplexMap1` an error occurs: Needs::nocont: Context ProgrammingInMathematica`ComplexMap1` was not created when Needs was evaluated. I don't know why, for the Help says "Needs["context`"] calls Get["context`"]. By convention, the file loaded in this way is the one which contains a package that defines context`. " I execute Mathematica 4.1 on Windows98 Thanks for any advice.