MathGroup Archive 2008

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

Search the Archive

SaveDefinitions in Manipulate is not saving definitions from packages

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94628] SaveDefinitions in Manipulate is not saving definitions from packages
  • From: dr DanW <dmaxwarren at gmail.com>
  • Date: Thu, 18 Dec 2008 07:20:44 -0500 (EST)

I asked a similar question previously, but I didn't do a good job of
describing the problem.

I am trying to send a notebook to a colleague who does not have access
to Mathematica.  There is a Manipulate statement that demonstrates the
results of my calculations that I want him to be able to work with.
As I understand it, this is one of the intended purposes for
MathPlayer.  However, I have run into a limitation that seriously
impedes my ability to do this.

Like any good programmer, whenever I create a useful function, I put
it into a package for later reuse.  As a consequence, I am always
using Needs[] in my notebooks to import the functions I have written.
The problem is that when I use Manipulate[args, SaveDefinitions->True]
any definitions from imported packages do not get saved.  Am I doing
something wrong, or is this a known limitation?

To reproduce, put the following minimal package code in a file called
SaveDefinitionsPackage.m in your $UserBaseDirectory/Applications
folder:

BeginPackage["SaveDefinitionsPackage`"]
SaveDefinitionsPackageTest::usage="SaveDefinitionsPackageTest[] prints
a message.";
Begin["`Private`"]
SaveDefinitionsPackageTest[]:="SaveDefinitionPackage loaded
successfully";
End[ ]
Protect[Evaluate[$Context <> "*"]]
EndPackage[ ]

And the following code in a different notebook (Test.nb):

Needs["SaveDefinitionsPackage`"]
Manipulate[
ToString[n] <> " " <> SaveDefinitionsPackageTest[], {n, 0, 10, 1},
SaveDefinitions -> True ]

Execute the notebook, save, close, kill the kernel, and reopen
Test.nb.  It is evident that the SaveDefinitionsPackageTest[] function
definition was not saved with the Test.nb notebook.

Any ideas?

Daniel


  • Prev by Date: Re: A version of With that binds variables sequentially
  • Next by Date: Re: NIntegrate Problem
  • Previous by thread: DeleteDuplicates uses a lot of memory
  • Next by thread: Giving an arbitrary number of arguments to Manipulate using Apply