MathGroup Archive 1997

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

Search the Archive

Loading packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9516] Loading packages
  • From: Steven Wilkinson <wilkinson at NKU.EDU>
  • Date: Sat, 8 Nov 1997 23:04:43 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Mathgroup,

I have a problem that I have seen pop up on this list from time to time,
but I can't make any of the answers that have appeared work. I can't
load the packages I write into Mathematica 3.0 with either Get or Need.
One response I saw  was given in the following message:

>If you are using Mathematica 3.x, you can do one of the following:
>
>   1)  Declare the cell containing the package commands to be an
>   initialization cell.  Highlight the cell, then from the Menu commands
>   select:  "Cell", "Properties", "Initialization".  Now save the
>   notebook and when the popup menu says "Auto Save Package" respond with
>   "Create Auto Save Package".  Mathematica will automatically save a copy of the
>   initialization cell as a package with the .m file extension.
>
>   OR
>
>   2)  Save the notebook as a package file.  You have to manually type in
>   the file name with the .m file extension in the dialog box
>   window--selecting the package file type from the drop down menu won't
>   do it.  This method should work in pre Mathematica 3.x versions.  But I found
>   that in some instances with pre Mathematica 3.x versions, there was a bug in
>   the notebook frontend and it was best just to write the package in a
>   standard text editor and save it with the .m file extension.
>
>   Dave Harvatin
>
>   On 31 Jul 1997 03:49:25 GMT, "jmt" <jmt at cybercable.tm.fr> wrote:
>
   >>If I write a package, say
   >>
   >>BeginPackage["myPackage`"]
   >>f::usage="f does strictly nothing"
   >>Begin["Private`"]
   >>f[_]=Null
   >>EndPackage[]
   >>End[]
   >>
   >>using an ordinary notebook, I will have to save it, let's say myPackage.nb
   >>If I read this notebook, using << or Get, the content of the file is not
   >>evaluated: no "myPackage`" context is happened to $ContextPath.
   >>
   >>It I use the command File->Save As Special->Package Format, I'm not asked
   >>wether I want the file to be either .nb or .m, the standard is .nb

I followed instruction set (2) on the above package. When I issued the
Get command

	<<myPackage.m

Mathematica responded with the error message

	Get : : Noopen :   Cannot open myPackage.m.

What am I doing wrong? Does this error message mean it couldn't find the
file "myPackage.m" or that once it found it it couldn't do anything
with it?

In another response to a similar question that dealt with the Needs
command, David Withoff said

>The Needs::nocont message is generated when Needs["context"] finds that
>"context" is not present in the value of $Packages. Since "context" is
>prepended to $Packages as one of the first  steps in evaluation of
>BeginPackage["context"], the appearance of this message usually means
>that BeginPackage["context"] hasn't been evaluated.  The first thing
>that I would do to solve this problem would be to take a close look at
>the .m file with an ordinary text editor.

What am I looking for?

Steve Wilkinson
Northern Kentucky University



  • Prev by Date: Re: Integrate[ ] returns If[ ] function; how to say it's True?
  • Next by Date: Re: Lists and Recursion
  • Previous by thread: Re: Lie symmetry package in mathematica
  • Next by thread: Loading Packages