MathGroup Archive 2011

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

Search the Archive

Re: package trouble

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117921] Re: package trouble
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Mon, 4 Apr 2011 06:31:25 -0400 (EDT)

You need to either...

* Start the document using File->New->Package.  This document will appear with a
slightly gray background, and Code cells will be the default cells that you
create.  When you save it, it will use the .m extension automatically.

or

* When you save the package file using File->Save As, you need to actually
change the file type in the drop-down underneath the filename in the File Save
dialog.  Changing the file extension by itself doesn't work...you have to direct
Mathematica to change the type of file.  One of the file types is "Mathematica
Package."

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.


On Sun, 3 Apr 2011 06:58:49 -0400 (EDT), Alexandru Chirvasitu wrote:
> Hi,
>
> This is a very frustrating problem. I'd appreciate any help you can
> provide.
>
> I'm trying to write a package; this has happened several times, with
> several packages, but most recently, I tried a very simple one that
> was suggested on this forum a while back, actually, by another user
> with a very similar problem:
>
> BeginPackage["anything`"]
> definition::usage="blablabla";...
> Begin["`Private`"]
> functions
> End[]
> Protect[functions]
> EndPackage[]
>
> I made sure the cell is an Initialization Cell, and I changed the
> style to "code". I saved in an appropriate directory both as
> anything.nb and anything.m, and then tried to read in the package with
>
> <<anything`
>
> What I got as output was
>
> Notebook[{Cell[
> BoxData[{RowBox[{"BeginPackage", "[", "\"anything`\"", "]"}], "
> ", RowBox[{RowBox[{RowBox[{RowBox[{"definition", "::", "usage"}],
> "=", "\"blablabla\""}], ";"}], "..."}], "
> ", RowBox[{"Begin", "[", "\"`Private`\"", "]"}], "
> ", "functions", "
> ", RowBox[{"End", "[", "]"}], "
> ", RowBox[{"Protect", "[", "functions", "]"}], "
> ", RowBox[{"EndPackage", "[", "]"}]}], "Code",
> InitializationCell -> True,
> CellChangeTimes -> {{3.51079*10^9, 3.51079*10^9}}]},
> WindowSize -> {715, 559},
> WindowMargins -> {{96, Automatic}, {4, Automatic}},
> FrontEndVersion ->
> "8.0 for Microsoft Windows (32-bit) (November 7, 2010)",
> StyleDefinitions -> "Default.nb"]
>
> If I try Needs["anything`"] I first get
>
> Needs::nocont: Context a` was not created when Needs was evaluated. >>
>
> and then th same RowBox mess as above.
>
> Does anybody have any idea what's going on? I should say, it has
> worked a bunch of times, but I can't see any pattern to it: most of
> the times it behaves like this, and only very rarely, it will go
> through. I should mention this is Mathematica 8, and the system is
> Windows XP.
>
> The other thread on MathGroup that I was referring to is here:
>
> http://forums.wolfram.com/mathgroup/archive/1999/Mar/msg00051.html
>
> There is only one response, regarding the package having to have the
> same name as the context (which is the case here), and also the need
> for the cell to be initialization (which again, is the case here).
>
> Please help; I'm desperate here :).
>
>
> Thank you,
>
> Al



  • Prev by Date: writing own package: cannot read it in..
  • Next by Date: Re: package trouble
  • Previous by thread: package trouble
  • Next by thread: Re: package trouble