Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2009

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

Search the Archive

Re: loading autosaved package using Needs[]

  • To: mathgroup at
  • Subject: [mg95120] Re: [mg95083] loading autosaved package using Needs[]
  • From: "David Annetts" <davidannetts at>
  • Date: Wed, 7 Jan 2009 04:07:10 -0500 (EST)
  • References: <>

 Hi Mitch,

> 	Needs["phd_thesis_common.m"]
> 	Needs::cxt: Invalid context specified at position 1 in 
> Needs[phd_thesis_common.m]. A context must consist of valid 
> symbol names separated by and ending with `. >>
> any help/suggestions appreciated.

When you usually load WRI-supplied packages, you don't specify the ".m"
extension, so why are you doing so here?

If you've defined your package using 


then as long as your working directory in in your search path, you can load
your package using 


Note the trailing "`" character & no ".m" extension.

There's a tutorial at tutorial/SettingUpMathematicaPackages in the
documentation but a very simple example follows.  Save the notebook as
test.nb after adjusting the directory, and don't evaluate the init cells 

(* cell 1 *)

(* cell 2: set these as init. cells *)
Working::usage = "Working[] should print Hello World";
Working[] := Print["Hello World"];
End[]; (* PRivate*)
(* end init cells *)

(* cell 3 *)
Quit[] (* don't use the package we just created -- force it to load from
disk *)

(* cell 4: don't evaluate init cells !*)



  • Prev by Date: Manipulate, Export, .avi, forward run without the slider in the
  • Next by Date: Re: Please answer to my questions,thank you.
  • Previous by thread: loading autosaved package using Needs[]
  • Next by thread: Re: loading autosaved package using Needs[]