MathGroup Archive 2007

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

Search the Archive

Re: Can you get a package back to a notebook easily?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83084] Re: Can you get a package back to a notebook easily?
  • From: AES <siegman at stanford.edu>
  • Date: Sat, 10 Nov 2007 03:39:41 -0500 (EST)
  • Organization: Stanford University
  • References: <fgen3e$flh$1@smc.vnet.net> <fgs7k8$3gb$1@smc.vnet.net> <200711081108.GAA26985@smc.vnet.net> <fh1cru$d2i$1@smc.vnet.net>

In article <fh1cru$d2i$1 at smc.vnet.net>,
 Murray Eisenberg <murray at math.umass.edu> wrote:

> 1. Converting notebook to a package.
> 

Thanks very much -- very helpful, copied and saved for future use.

[And full text of reply left appended below, in case someone else 
encounters this later on.]

=====================================================
In article <fh1cru$d2i$1 at smc.vnet.net>,
 Murray Eisenberg <murray at math.umass.edu> wrote:

> 1. Converting notebook to a package.
> 
>     This assumes you've written code in the notebook that includes the
> appropriate extra stuff for good package functionality...
> 
>     BeginPackage["topName`pkgName`"]
> 
>     ThisFunc::usage="describe thisFunc";
>     ThatFunc::usage="How to use thatFunc";
> 
>     Begin["`Private`"]
>     (* definitions of objects here *)
> 
>     End[]
> 
>     EndPackage[]
> 
> All these cells (except possibly comments), but not text cells, should
> be made, by the Cell > Properties menu item, into Initialization Cells
> that are Active.
> 
> Save the notebook with name pkgName.nb.  When asked if you want to
> automatically save this as a package, too, answer yes.  Automatically,
> wherever the notebook MyNB.nb is saved, you'll get the corresponding
> pkgName.m package file in the same directory.
> 
> 2. Move (or copy) both the .nb file and the .m file into a subdirectory, 
> named topName, of InstallationDir\AddOns\Applications\  (where
> InstallationDir refers to the top-level directory of the Mathematica
> tree -- the value of the Mathematica system variable $InstallationDirectory.
> 
> That's it.
> 
> When you want to revise the package, revise the "auto-save" notebook you 
> thereby created in step 1, and when you save the notebook, it will
> automatically update the package accordingly.
> 
> 3. To use the package,
> 
>     Needs["topName`pkgName`"]
> 
> or:
> 
>     <<topName`pkgName`
> 
> Re Step 2, of course you can keep a copy of the original saved notebook
> and auto-saved package .m file elsewhere and work on revisions there
> before moving the new versions as explained in Step 2.
> 
> This is just a brief (and, I hope, entirely correct) outline of a
> process that has many variants, e.g., with respect to where you may put
> packages, or how to make packages load automatically whenever you open
> Mathematica.
> 
> Murray Eisenberg                     murray at math.umass.edu
> Mathematics & Statistics Dept.
> Lederle Graduate Research Tower      phone 413 549-1020 (H)
> University of Massachusetts                413 545-2859 (W)
> 710 North Pleasant Street            fax   413 545-1801
> Amherst, MA 01003-9305


  • Prev by Date: Re: Single most useful dynamic/interactive capability in Mathematica?
  • Next by Date: Re: Matrix multiplication speed up
  • Previous by thread: Re: Re: Can you get a package back to a notebook easily?
  • Next by thread: Re: Can you get a package back to a notebook easily?