Re: Package writing

*To*: mathgroup at smc.vnet.net*Subject*: [mg67256] Re: Package writing*From*: albert <awnl at arcor.de>*Date*: Wed, 14 Jun 2006 06:29:35 -0400 (EDT)*References*: <e6lhqr$nfs$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi marek, > I have the following problem. I used Template.nb to create a package. how exactly are you creating the package from Template.nb? Via the autocreate-package functionality or by an explicit 'save as' -> 'Package file' or ...? > During the whole process I had some problems trying to get it to work > although the same commands in a different (fresh/new notebook) produced > desired results. Right now the sutuation is as follows. I can use my > poackage if I load it into any notebook but it does not work in the > original notebook I used to write it. a blind guess is that maybe you are (automatically) executing the initialization cells in the original notebook and this makes problems. Do you get a dialog when starting a new kernel which asks you whether or not to evaluate the initialization cells? what is your answer to that? It should be 'no' for the process you describe... > I have that notebook and the > associated m file in /home/marek/Mathematica/Packages. Here are first 4 > command I execute in the original notebook > 1. SetDirectory["/home/marek/Mathematica/Packages"] > This sets my working directory to the directory in which my package is > located. This is not really necessary for the Needs to succeed, _if_ you do 2. (which is the thing I would recommend). > 2. AppendTo[$Path, "/home/marek/Mathematica/Packages"]; > Here I append this very same directory to my search path so that I can > load that package in the same notebook for testing purposes. looks reasonable, something that I do all the time. Maybe to make sure to import this very package you might want to use PrependTo instead of AppendTo, though. Just make sure no conflicts with other package files in that directory arise... > 3. Needs["DataAnalysis`"] > This line loads that package. When I execute that line I get no > complaints form Mathematica that it cannot open something or anything > like that > After those there is a bunch of cells with the implementation of my > ppackage all of which are set to be an Initialization cells. > After them I have few cells which are using functions from my package > but they do not work. The symbols/functions defined in that package > seems to be recognized because Ctrl=k combination does the > autocomplition but nothing happens when I execute a cell with a funcion > defined in my package. Check the context and definitions of these symbols with: ??functioname This will give you the right pointers, I'm pretty sure... > On the other hand I can copy my package to > /home/marek/.Mathematica/AutoLoad directory (and I do it changing the > name of that m file) and it works fine from there after I open new > notebook and load it with Needs["DD`"] (I chnaged the name of that file > to DD.m) without editing? Do you use something like BeginPackage[] for your Package? If not, I wonder why you don't get error messages from your Needs[]... > In a fresh notebook I can execute that AppendTo command from above and > then load my package from the original development directory (it has > different name there so I know that it is that version which is being > loaded not the one from /home/marek/.Mathematica/AutoLoad) and it will > work fine. Wrong guess: the package in AutoLoad will be loaded, even without an explicit Needs for it whenever a new kernel is started. That's the purpose of the AutoLoad-directory after all and the name should be a hint for that. For the purpose you are (miss)using AutoLoad you should better use the directory ~/.Mathematica/Applications, which is designed (AFAIK) to store personally installed (third-party) packages, where third party can of course be yourself. > So why I cannot use my package from the original notebook I wrote it > in? I don't know, can you construct a minimal example and post it? Without that, understanding the problem is nearly impossible. As supposed above, you should use ??symbolname for all symbols in your package to check for context, definition etc. and try to understand what's wrong with that information. Other than that I can just assure you that I am doing exactly what you try all the times and it works perfectly, so it definitly is possible and if you have more details I might be able to help... > Any suggestiones greatly appreciated hth, albert

**RE: Resolve/Reduce is taking forever**

**Re: Determining continuity of regions/curves from inequalities**

**Re: Package writing**

**Re: Package writing**