MathGroup Archive 2010

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

Search the Archive

Using package functions in Manipulate/DynamicModule

  • To: mathgroup at
  • Subject: [mg109108] Using package functions in Manipulate/DynamicModule
  • From: Rui <rui.rojo at>
  • Date: Mon, 12 Apr 2010 23:03:24 -0400 (EDT)

Hey. My objective is to deploy in a Mathematica Player file a document
which has some interactive stuff, without any code visible. Ideally,
it would be all in a single file but I can live with sending a .m
package file too. So far so good.

Inside a DynamicModule I used some functions from a .m file I had
created some time ago. As expected, when I close the file and reopen
it, the dynamic gives errors everywhere.

First I thought there might be something magical similar to
SaveDefinitions that would automatically store in the cell everything
it needs to work fine. But I coulnd't find it. I tried wrapping it up
in a Manipulate with SaveDefinitons->True but doesn't work either.

So, I decided to try for the cell to just load the package whenever it
needs to be displayed for the first time.
"Initialization:>Needs["AddOns'"]" seemed to be perfect. However, it
doesn't work as expected.
For example: (SS and IListPlot are from AddOns.m)
IListPlot[SS[p, 100] @@ Range[100]], {p, 1, 100, 1},
 Initialization -> Needs["AddOns`"], SaveDefinitions -> True]
doesn't work and tells me there are double definitions in Global` and
AddOns` of IListPlot and SS (right after starting the kernel)

The few times I've tried to use "Initialization" it gave me a
headache. I would have thought it just executes that whenever the
dynamicmodule/manipulate is displayed for the first time, but evidence
proves it isn't that simple, and I don't get it.

Perhaps I should put all of my package's variables in the
DynamicModule and copy the whole package inside?
When something that strikes me as useful and common is getting
convoluted and messy, it's a sign I'm overseing something and needing
your help.

Thanks a lot! ;D

  • Prev by Date: Re: Bug in PadLeft/PadRight
  • Next by Date: Re: beginner question about syntax
  • Previous by thread: Re: Converting the integral of a sum into a sum of integrals
  • Next by thread: Re: Using package functions in Manipulate/DynamicModule