MathGroup Archive 2002

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

Search the Archive

RE: Re: Package problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34836] RE: [mg34826] Re: Package problem
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 9 Jun 2002 05:10:04 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Graham,

The first time you put Initialization cells in a notebook and save it,
Mathematica will ask you if you want to create an AutoSave Package. If you
didn't create an AutoSave Package then, Mathematica will not ask you again.
(It assumes that you just want a notebook with a few initialization cells.)

If you have an old notebook with Initialization cells, that you now want to
make into an AutoSave Package notebook, use Option Inspector (Ctrl-Shift-O).
Show option values for notebook. Then go to Notebook Options, File Options
and set AutoGeneratedPackage to Automatic. The notebook will now write your
.m file for you each time you save it.

I have written many packages, but I have never used Save->Special->Package.
The procedure above is the convenient way to do it. Again, you should
normally never have to directly edit, or even look at, a .m package file.

It is a shame that the direct simple way to create and maintain packages
does not seem to be documented in a coherent single place in the regular
Mathematica documentation. Many people seem to have problems with it, as
indeed I did when I first started out.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: Graham [mailto:lamontgra at yahoo.com]
To: mathgroup at smc.vnet.net
>
> David
> Thanks I think I'm getting there but I still not clear about some
> things:
>
>  > Graham,
> > >
> > > The package starts :
> > > BeginPackage["Roulette`BallSim1`"]
> > >
> >
> > So far, so good. Now create a folder named Roulette in the
> > AddOns\ExtraPackages folder. Put your package notebook there.
> Your package
> > notebook should have the name BallSim1.nb. Make all of the statements in
> > your notebook separate cells as far as possible. And make them
> > Initialization cells. When you save your notebook choose to create an
> > AutoSavePackage.
>
> How do I do this ?
> Sometimes Mathematica asks " Do you want to create an AutoSavePackage ?"
> But sometimes not. How can I force this ?
>
> When I try Save->Special->Package:
> It says its saving as *.m but then saves as *.nb and asks to overwrite
> the notebook I'm using!
>
> This will create the BallSim1.m package file and each time
> > you modify the BallSim1.nb notebook and save it, the package
> file will also
> > automatically be updated. You should never have to directly
> edit a .m file.
> >
> > Now load the package with
> >
> > Needs["Roulette`BalSim1`"]
> >
> > Also, I'm believe the names are case sensitive. Notice that the leading
> > context names are like directory paths. Mathematica
> automatically looks in
> > StandardPackages and ExtraPackages so you only have to give the
> context path
> > from that point down. That should work.
> >
> > David Park
> > djmp at earthlink.net
> > http://home.earthlink.net/~djmp/
> >
> > > From: Graham [mailto:lamontgra at yahoo.com]
To: mathgroup at smc.vnet.net
> > >
> > > I am trying to create a package and read it in.
> > >
> > > The package starts :
> > > BeginPackage["Roulette`BallSim1`"]
> > >
> > > BallFall::usage = "Performs simulation of ball motion through fluid"
> > >  (* BallFall
> > >     a:: drag coefficient (a*v^2)
> > >
> > >
> > > But I get this:
> > >
> > > Get["ballsim1`"]
> > > Notebook[{Cell[
> > >       BoxData[{RowBox[{RowBox[{"BeginPackage", "[",
> > > "\"Roulette`BallSim1`\"",
> > >                   "]"}], "\n"}], "\[IndentingNewLine]",
> > >           RowBox[{RowBox[{"BallFall", "::", "usage"}], "=", " ",
> > >               RowBox[{"\"Performs simulation of ball motion
> > > through fluid\"",
> > >                    "\[IndentingNewLine]", " "}],
> > >               RowBox[{"(*", " ",
> > >                   RowBox[{"BallFall", "\n",
> > >                       RowBox[{RowBox[{"a", "::", " ", "drag"}], " ",
> > >                           "coefficient",
> > >
> > >
> > > Whtas happening ?
> > > Is the file corrupt perhaps ?
> > > Can you edit .m files in the notebook interface ?
> > >
> > > Thanks
> > > Graham
> > >
>



  • Prev by Date: Re: which Linux does Mathematica run on?
  • Next by Date: Re: which Linux does Mathematica run on?
  • Previous by thread: RE: Re: Package problem
  • Next by thread: Generic Mathematica NonlinearRegress Question