Group Abstract Group Abstract

Message Boards Message Boards

0
|
13.2K Views
|
10 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Can not read a package name_package.m in my laptop using Mathematica 9.

Posted 11 years ago

Hello Dear Community:

I want to ask something about a problem with Mathematica 9. My Wolfram Mathematica 9, can not read some package, like name_package.m. I'm working inside where I can find name_package.m . Now, some one can tell me what is the problem about this.

Really, I changed again the Mathematica version, and I can not solve this problem. In another PC and laptop I run this package very well. But, I can not find the answer for my problem in my laptop (a Ultrabook ASUS) I appreciate your time and any comment.

Regards,

PA

POSTED BY: pedro allendes
10 Replies

Let me outline a procedure, which I think would save a lot of people a lot of trouble.

First, instead of using the term "package" let's use the term "application". A package may always be considered to be part of an application but an application does not necessarily have to include a package. An application might be any group of folders and files associated with some subject that you want to keep together.

WRI has provided a standard place to put applications and that is in the $UserBaseDirectory/Applications folder. You can find the UserBaseDirectory by evaluating in a notebook:

$UserBaseDirectory

(My experience is that many people I communicate with will put their packages anywhere but there. They always have some reason but THAT IS THE BEST PLACE TO PUT A PACKAGE.) The reason that this is the best place is that Mathematica automatically looks there for not only packages but also palettes and style sheets, which will automatically appear in your menus. It will also look there for an init.m file that you might want to associate with that application. If you someday add documentation Mathematica will also find it. Secondly, it is part of your own personal files and will persist independent of Mathematica updates. Another advantage is that the application packages can be loaded in a uniform manner from any notebook in any location. If you want to make links to other notebooks associated with the application you know exactly where to look for them. You never have to get involved in setting directories. If you want to send the entire application to someone else you can just zip it up, send it to her and she only has to unzip it into her $UserBaseDirectory/Application folder. Those are all significant advantages. Even if you are starting out with a modest application, say with just a package, that is still the best place because you can easily expand it later into a more elaborate application.

So your file structure might look something like the following (where I am showing how various optional elements might be included):

$UserBaseDirectory/Applications/
     ProjectX/ (* top folder for the application *)
     Documentation (* any documentation you might later add via Workbench  *)
     FrontEnd/
           Palettes/ any palettes
           StyleSheets/ any style sheets
     Kernel/ init.m
     package1.m
     package2.m
     MyTutorials/ perfected notebooks associated with ProjectX 
     DevelopmentNotebooks/ ...
     SallysNotebooks/ notebooks done by an associate.

But you might start out with just the top folder, the package and maybe a working folder for notebooks associated with the project.

The BeginPackage statements for your packages would look like:

BeginPackage["ProjectX`package1`",{...}]

Notice that the path from the Application folder is included in the package name here. ProjectX is part of the Context. Then a user could, from anywhere, load one of the packages with, say:

<<ProjectX`package1`

But a much better method is to write an init.m file that looks like this:

<<ProjectX`package1`
<<ProjectX`package2`

Then WRI has implemented a neat shortcut such that the entire application can be loaded with:

<<ProjectX`

When Mathematica sees only a top level folder in the Get statement it automatically looks for the init.m file in the application and evaluates it.

So when you think package, think application instead and, if you get off on the right foot, things will go much smoother from that point on.

I wish that I could help more. I hope this gets resolved.

POSTED BY: David Reiss
Posted 11 years ago

Thank you Mr. D. Reiss, You are very kindly for your time and atenttion! I will tray to contact directly then. Regards.

POSTED BY: pedro allendes

Unfortunately these are details that I do not have suggestions for. I would suggest that you contact Wolfram Customer Support (unless someone here has additional suggestions for help):

http://www.wolfram.com/support/contact/

POSTED BY: David Reiss
Posted 11 years ago
POSTED BY: pedro allendes

Thanks Bruce! I forgot about that.

POSTED BY: David Reiss

fyi, The Community editor interprets underscore characters and dollar sign characters as formatting commands if they are not escaped with a backslash (\) or in backquotes (``). I patched your posts; I hope they get across your meanings better now.

POSTED BY: Bruce Miller
POSTED BY: David Reiss
Posted 11 years ago

Thank you for your comments Mr. D. Reiss. The form that I'm reading the special package is using the next sentence:

<<NamePackage.m 

My NamePackage.m is located in a folder, it's name is "The_Program". If my Mathematica can not read NamePackage.m like I explained before, I change the "Directory" and I force that Wolfram is working in "The_Program" folder. Now, run the package again, but, I have a problem again, can not read the package correctly!. I appreciate your time and attention.

POSTED BY: pedro allendes

A couple of quick comments or suggestions.

The first is, depending upon how you are trying to load your package, you should determine whether Mathematica knows where to look for your package. How are you trying to load it and where is that package located on your system?

Second suggestion is that you do not use _ characters in the name of your package. This potential he can cause problems in your code because the _ character has a meaning in Mathematica to indicate a pattern. Problems might not happen, but it is best to avoid their potentiality.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard