MathGroup Archive 1998

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

Search the Archive

Re: writing programs

  • To: mathgroup at
  • Subject: [mg13476] Re: writing programs
  • From: "Paul A. Rombouts" <paromb at>
  • Date: Sun, 26 Jul 1998 02:33:36 -0400
  • Organization: World Online
  • References: <6p6rgt$>
  • Sender: owner-wri-mathgroup at

John M. Dlugosz wrote in message <6p6rgt$5lf at>...
>How do you write programs in Mathematica?  I'm asking about the
>mechanics  of preparing the files, not the language reference.
>I looked at a simple .m file, and see that it's plain text as I would
>input it.


>Second, typing input text is fine for C++ or Perl, but won't let me get
>all the fancy stuff in Mathematica.  I'd rather use the notebook
>This package I'm looking at says I can rename the .nb file to .m and it
>will work, too.  But I wonder how?  If all the cells are executed in
>order when I load the "package", what happens to all the examples and
>Just what happens when I "load" such a renamed file as a package?

Hi John,

I think you'll find answers to most of your questions in sections 1.11.1
and 2.11.1 of the Mathematica book (third edition). When I write
packages I usually create a notebook using the front end. Then I mark
the cells containing code I want to include in the package as
initialization cells and save the notebook. Mathematica automatically
asks me whether I want to create an "Auto Save Package". When you
answer affirmatively, "This will cause the front end to automatically
maintain a package (.m) in the same directory as the notebook. The
package will contain all the initialization cells from the notebook; it
will be updated each time the notebook is saved."
You can look at the files ChaosGame.nb and ChaosGame.m in the
subdirectory AddOns\ExtraPackages\ProgrammingInMathematica\ of the main
Mathematica directory for an example of a package made this way. In
case Mathematica fails to ask you if you want to create an "Auto Save
Package", you can set the option Notebook Options/File
Options/AutoGeneratedPackage using the option inspector. I hope this

Paul A. Rombouts <P.A.Rombouts at>

  • Prev by Date: Re: discrete math, how many zeroes in 125!
  • Next by Date: Re: Re: RE: Re: Re: Non-comm
  • Previous by thread: Re: writing programs
  • Next by thread: Fw: writing programs