MathGroup Archive 2009

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

Search the Archive

Re: Needs[], BeginPackage[], filename

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101053] Re: [mg101038] Needs[], BeginPackage[], filename
  • From: "David Park" <djmpark at comcast.net>
  • Date: Tue, 23 Jun 2009 07:02:36 -0400 (EDT)
  • References: <3942571.1245660085380.JavaMail.root@n11>

1) Create a folder MyApplication (say) in your private
Mathematica/Applications folder. (Evaluate $UserBaseDirectory to find this.)

2) Write a notebook called MyPackage.nb (say) that contains all your package
code. Make all the cells Initialization cells. Make the BeginPackage
statement:

BeginPackage["MyApplication`MyPackage`"]

3) Save MyPackage.nb in the MyApplication folder and when you first save it
choose Save as Autogenerated Package. This will create the MyPackage.m file
in the same folder. Every time you change and save the MyPackage.nb notebook
the MyPackage.m package file will also be automatically updated. You should
normally never have to look at the MyPackage.m file.

4) Load the package with:

Needs["MyApplication`MyPackage`"]

The Presentations package has a simple example of developing a package and a
sample package notebook that spells everything out in more detail.


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  



From: Scot T. Martin [mailto:smartin at seas.harvard.edu] 

Needs[] allows the context and filename to be specified.

BeginPackage[] allows a context and not a file name.

Then, my packages require two steps, as in the following example:

** start **

Needs["sizedistribution`", "size functions.m"]

BeginPackage["tandemdma`", {"sizedistribution`"}]

** stop **

Are two steps really necessary or am I missing something very simple?

My goal would be to just forego Needs[] and handle everything in one step 
with BeginPackage, but I cannot figure out a way to feed the filename to 
BeginPackage[].

I had a search on the MathArchives, but I did not succed in locating any 
material addressing this question.

Thanks for any quick hints!








  • Prev by Date: Re: Ansatz?
  • Next by Date: Re: Slow performance gathering property data from fitted
  • Previous by thread: Re: Needs[], BeginPackage[], filename
  • Next by thread: Re: Needs[], BeginPackage[], filename