RE: path for package
- To: mathgroup at smc.vnet.net
- Subject: [mg70391] RE: [mg70366] path for package
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 15 Oct 2006 00:19:01 -0400 (EDT)
1) How did you make your .m file? The easiest method is to make a regular Mathematica .nb notebook with the package statements as Initialization Cells. Say that your notebook is named mypackage.nb Save the notebook as an Auto Save Package, which automatically creates the my package.m file. (You do this with the regular Save or SaveAs command and the Auto Save Package choice comes up the first time you save. You can also specify this in the Option Inspector.) You never have to look at the mypackage.m file. Each time you update mypackage.nb and save, the mypackage.m file will also be updated. 2) Create a folder 'myfolder' in your Applications folder and put the notebook and package there. (Actually create this folder first and put the notebook there to begin with.) So you will have C:\Documents and Settings\Administrator\Local Settings\Application Data\Mathematica\Applications\myfolder\ mypackage.nb mypackage.m 3) Now to tie this all together write your BeginPackage statement as follows: BeginPackage["myfolder`mypackage`"] That is, the BeginPackage statement gives the path from the Applications folder (where Mathematica will automatically look) to your package. 4) Load the package from anywhere with Needs["myfolder`mypackage`"] or <<myfolder`mypackage` Of course, 'myfolder' and 'mypackage' can be any names you choose. It is better to have a package in a specific folder where users and Mathematica can always find it than to just have it lying around anywhere. Also, this then works just like the standard packages. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Akane Tendo [mailto:odneTenakA at gmail.com] To: mathgroup at smc.vnet.net Hello, In which user directory should I put a package .m file to load the package? I already tried C:\Documents and Settings\Administrator\Local Settings\Application Data\Mathematica\Applications but then I load the package and it fails. Thank you!