From: Miguel Galrinho on
I have a package in Mathematica that works fine when I open the .m file and
click "Run Package". However, when I type Needs[.] in a notebook, the
package doesn't load 100%, only some functions do. The file begins with



BeginPackage[".", {.}]



like I think it was supposed to. I don't know what might be wrong.



Can anyone help?



Thanks.



Miguel Galrinho

From: David Park on
1) Evaluate $UserBaseDirectory and look for the Applications folder there.

2) In the Applications folder create a folder for your package application,
MyApplication for example.

3) Say that your package is saved as MyPackage.m. (You might also have a
MyPackage.nb if you are using that method to create the .m file.) Put these
files in the MyApplication folder.

4) Write the BeginPackage statement as:

BeginPackage["MyApplication`MyPackage`", {dependent packages if any}]

Notice that the first argument of BeginPackage gives a kind of file path
from the Applications folder to the package file.

5) Load the package with:

Needs["MyApplication`MyPackage`"]

or

<<MyApplication`MyPackage`

6) But you say that some routines don't load with your Needs statement. All
that I can think is that they are not mentioned in the public section of the
package with usage statements. Use a

MyRoutine::usage = "MyRoutine[args...] with a description.";

for each routine that you want exported by the package. Put these statements
after the BeginPackage statement but before the Begin["`Private`"]
statement.


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: Miguel Galrinho [mailto:miguel(a)galrinho.com]


I have a package in Mathematica that works fine when I open the .m file and
click "Run Package". However, when I type Needs[.] in a notebook, the
package doesn't load 100%, only some functions do. The file begins with



BeginPackage[".", {.}]



like I think it was supposed to. I don't know what might be wrong.



Can anyone help?



Thanks.



Miguel Galrinho



From: Bill Rowe on
On 6/30/10 at 1:50 AM, miguel(a)galrinho.com (Miguel Galrinho) wrote:

>I have a package in Mathematica that works fine when I open the .m
>file and click "Run Package". However, when I type Needs[.] in a
>notebook, the package doesn't load 100%, only some functions do. The
>file begins with

>BeginPackage[".", {.}]

>like I think it was supposed to. I don't know what might be wrong.

>Can anyone help?

Your BeginPackage call looks like it would be a problem.
Choosing a one character name for the context name is a poor
choice. And it is a particularly poor choice to use a character
such as a single "." that is used extensively for other purposes
and could result in conflict and unpredictable behavior.

Next, the second argument to BeginPackage is optional and used
to cause another package to load that the package you are
creating depends on. This argument is a list of *strings* not a
single . character. It should be possible to make this second
argument something that evaluates to a list of strings. But
clearly a single . character won't do this. And if the list
contains the same string as used to name the context being
defined by BeginPackage (the first argument) there is certainly
going to be a problem of some sort.

Try changing BeginPackage[".", {.}] to say
BeginPackage["myPackage"] and see if this helps.

If this doesn't fix the problem, you will need to supply more
detail of what you are doing. Do you have a private context
declared within the context you are setting up with
BeginPackage? If so, you will need public usage messages for
those functions defined inside the private context to easily
access them outside of the private context.

Also, when you say not all of the functions are loading how are
you determining that?


From: Patrick Scheibe on
Hi,

did you export all functions by giving them a usage?

Cheers
Patrick

Am Jun 30, 2010 um 7:50 AM schrieb Miguel Galrinho:

> I have a package in Mathematica that works fine when I open the .m
> file and
> click "Run Package". However, when I type Needs[.] in a notebook, the
> package doesn't load 100%, only some functions do. The file begins
> with
>
>
>
> BeginPackage[".", {.}]
>
>
>
> like I think it was supposed to. I don't know what might be wrong.
>
>
>
> Can anyone help?
>
>
>
> Thanks.
>
>
>
> Miguel Galrinho
>


From: Miguel Galrinho on
Thank you both for your help, but unfortunately the problem still persists.
I have all functions with a usage, so that's not the problem. The program
recognizes the functions (the help files work, for example), but doesn't run
them (using "Needs", because running the package by opening it and clicking
"run package", everything works).

Another thing I forgot to say before was that this package used to work fine
in Mathematica 5, but this problem happens with Mathematica 7. But I don't
think the problem has to do differences on the code, because otherwise it
wouldn't work when I click "run package" or when I evaluate all the cells in
the notebook. Do you think it might be anything to do with that?

Thanks again for your help.

Best regards,

Miguel Galrinho

-----Mensagem original-----
De: Patrick Scheibe [mailto:pscheibe(a)trm.uni-leipzig.de]
Enviada em: quarta-feira, 30 de Junho de 2010 13:16
Para: Miguel Galrinho
Cc: mathgroup(a)smc.vnet.net
Assunto: Re: Run Package vs Needs

Hi,

did you export all functions by giving them a usage?

Cheers
Patrick

Am Jun 30, 2010 um 7:50 AM schrieb Miguel Galrinho:

> I have a package in Mathematica that works fine when I open the .m
> file and
> click "Run Package". However, when I type Needs[.] in a notebook, the
> package doesn't load 100%, only some functions do. The file begins
> with
>
>
>
> BeginPackage[".", {.}]
>
>
>
> like I think it was supposed to. I don't know what might be wrong.
>
>
>
> Can anyone help?
>
>
>
> Thanks.
>
>
>
> Miguel Galrinho
>

Nenhum v=EDrus encontrado nessa mensagem recebida.
Verificado por AVG - www.avgbrasil.com.br
Vers=E3o: 9.0.830 / Banco de dados de v=EDrus: 271.1.1/2972 - Data de
Lan=E7amento: 06/30/10 07:36:00