MathGroup Archive 2007

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

Search the Archive

Re: Creating and installing one's own packages?

  • To: mathgroup at
  • Subject: [mg82760] Re: Creating and installing one's own packages?
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Tue, 30 Oct 2007 03:39:04 -0500 (EST)
  • References: <fg4d7v$68l$>

AES wrote:
> I have a general understanding of what a 'package' is.  

A package is just a plain text file, with the extension .m, containing 
some Mathematica expressions.  The expressions are evaluated when you 
read in the package.

In[1]:= << "abc.m"
will read in and evaluate the contents of the file abc.m, if abc.m is in 
the current directory, Directory[].  (But see the 
MathematicaFileOrganization tutorial I mention below!)

> I understand (I 
> think) that one can prepare a notebook, and then save (or install?) that 
> notebook as a package.

A notebook cannot be used as a package, but (as you note below), it is 
possible to maintain .m files based on notebooks.

> And somewhere in the fragmented documentation 
> on packages I also found the sentence:
>       "There are also capabilities that allow packages set up to 
>          correspond to notebooks to be maintained automatically."
> N ow, the tutorial "Setting Up Mathematica Packages" gives me a model  
> or outline or template for a package, which I can use as a guide to 
> create ("set up?") my own package -- as a notebook, anyway.
> But I'll be g-ddamned if I can find anywhere, in that tutorial or 
> anywhere else in the Mathematica 6 documentation, explicit instructions 
> on:
> *  How to then convert that notebook into a package, or  
>    where to save it as such after conversion.

If you have some initialization cells (Cell -> Cell properties) in the 
notebook, Mathematica will ask you before saving whether you would like 
it to automatically maintain a package (.m) file, with the same content 
as the initialization cells.  If you enable this, then the .m file will 
be automatically updated whenever you save the notebook.

> *  Where to save the parent notebook itself (or a copy of it), 
>    as an unconverted notebook.

The .m file will be in the same directory as the .nb file.

You may want to read these:


> *  How to later modify or edit or update the package itself,
>    as I'm likely to want to do:  Update the package itself?
>    (And if so, how to get at it?)  Update the parent notebook
>    and then convert -- and Install? -- again?
> [Note that the word "Install" does not seem to appear anywhere in the 
> "Setting Up Mathematica Packages" tutorial.]


  • Prev by Date: Re: Two sphers joined by a line and moving on an ellipse! (animation)
  • Next by Date: Re: wrong answer or no answer?
  • Previous by thread: Frequency response function
  • Next by thread: Problem with supplying custom tick marks