Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Package writing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67280] Re: Package writing
  • From: "marek" <MarekBr at gmail.com>
  • Date: Thu, 15 Jun 2006 03:26:30 -0400 (EDT)
  • References: <e6lhqr$nfs$1@smc.vnet.net><e6oq7b$si8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Albert

> how exactly are you creating the package from Template.nb? Via the
> autocreate-package functionality or by an explicit 'save as' -> 'Package
> file' or ...?

  I have to say that I do not know what the autocreate-package
functionality is but I know that when I save a notebook with
initialization cells they are being written into an .m file and I
relied on that method to create the package.

> 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...

That is exactly what I do. Please see my other reply to another message
in that thread which I just submitted. I outline all the steps I do
after opening my notebook untill I can see that the package is not
working.

> This is not really necessary for the Needs to succeed, _if_ you do 2. (which
> is the thing I would recommend).

  I set the directory so that my .m file is written in that location.

> 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...

  I did try PrependTo at some point but that did not solve my problem.
I will have a look and check if there are some other files with the
same name in the directories included in $path variable.

>
> Check the context and definitions of these symbols with:
> ??functioname
>
>  This will give you the right pointers, I'm pretty sure...

I am not sure if I know what to expect from that command so here are
the first two lines of the output after executing ??BcgSubtract

BcgSubtract[data,n] tries to estimate the background and subtracts it
from \
the input data file.
BcgSubtract[DataAnalysis`Private`data_, DataAnalysis`Private`fr_ : 20.]
:=
  Module[{DataAnalysis`Private`temp, DataAnalysis`Private`m,

and further down I see basically my module with DataAnalysis`Private`
appended to each and every variable. Does that look reasonable?

> 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[]...

  No editing. I do have BeginPackage[] and EndPackage[] in my notebook.

> 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.

  Yes I agree that the name of that directory is very suggestive.
However if I open Mathematica and have fresh, clean blanck notebook in
front of me non of the functiones from my package (a copy of which is
in .Mathematica/AutoLoad directory) is recognized (The autocomplition
does not work). It only works after executing Needs[] commands. Is
there something wrong with my Mathematica? I am using version 5.1 on
Gentoo Linux box.

> 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...

  It is probably something simple I am missing here. If You don't mind
could You please go to my website at www.physics.mun.ca/~marek and I
will post my notebook there so that You could grab it and play with it.
Please keep in mind that it is my first package so thing might not be
done 100% the "Mathematica" way.
Look for DataAnalysis.nb link on the front page

Marek


  • Prev by Date: Re: Re: new slide template: how change?
  • Next by Date: Re: Getting the (correct) roots of a polynomial
  • Previous by thread: Re: Package writing
  • Next by thread: Re: Package writing