MathGroup Archive 2001

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

Search the Archive

Re: Problem in loading own Package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27145] Re: Problem in loading own Package
  • From: jkf at beatmail.com
  • Date: Wed, 7 Feb 2001 02:12:50 -0500 (EST)
  • References: <95l38f$e2r@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Someone else may have a more elegant or easier way of doing this but
this is how I deal with customized packages.

The proper syntax for the Needs function is the following:

Needs["context`file`"]

Your attempts do not have the quotations in the proper order,
nor do they contain the package context, which refers to the name of
the folder where your package is located. Check out
the ..\AddOns\StandardPackages folder and see how the other (built-in)
packages are organized.  I  place the packages I write myself in a
special folder within the path of the Mathematica StandardPackages.
For example,

C:\Program Files\Wolfram
Research\Mathematica\4.\AddOns\StandardPackages\myPackages

If the package myPoisson.m resides in the myPackages folder,
the Needs function to call this package looks like this:

Needs["myPackages`myPoisson`"]


Good luck,

John


In article <95l38f$e2r at smc.vnet.net>,
  Ossama Kullie <kullie at hrz.uni-kassel.de> wrote:
>
>
> Dear Mathematica users can you help me?
>
> I have written the folloing  package
>
> BeginPackage["Poisson`"]
>  Clear[PoissonBracket]
> PoissonBracket::usage = "PoissonBracket[a, b,n] calculates the Piosson
> bracket for tow functions a and b which depend on the variables p, q"
> Begin["`Private`"]
> PoissonBracket[a_, b_, n_] := Block[{pk, n},
>       pk =
>         Simplify[
>           Sum[D[a, q[i]]* D[b,p[i]] - D[a,p[i]] * D[b,q[i]],
{i,1,n}]]]
> End[]
> EndPackage[]
>
>  and I have put it in a file Poisson.m, and  tried all possibilties to
> load the package but it doesnot work!
>  Mathematica has read the file Poisson.m, but the function
PoissonBracket
>  is not created
>   As Example :
>  Needs["Poisson`", "Poisson.m"]
>  give the folloing error
>  Needs::nocont: Context Poisson` was not created when Needs was
>  evaluated.
>  or: <<Poisson`
>      then
>      ?? PoissonBracket
>      Information::notfound: Symbol PoissonBracket not found.
>
>  or: Get["Poisson.m"]
>    and then
>    ?? PoissonBracket
>    nformation::notfound: Symbol PoissonBracket not found.
>
>    the folloing information may be usfel to anser my quation
>    $ContextPath
>    Context[Poisson]
>    ?? Poisson
>
>    this give the Output
>
>   {"Global`", "System`"}
>   "Global`"
>   "Global`Poisson"
>  the funktion PoissonBracke work very well, when I create it in my
>  Notebook, only in a package doesnot!
>  I cannot find any error, why I cannot load the
>  function PoissonBracket from the pachage? .
>
>


Sent via Deja.com
http://www.deja.com/


  • Prev by Date: FW: AW: LogPlot/Plot-Identity
  • Next by Date: Re: assigning parameters from a matrix
  • Previous by thread: Re: Problem in loading own Package
  • Next by thread: Re: Problem in loading own Package