MathGroup Archive 2010

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

Search the Archive

Re: Using package functions in Manipulate/DynamicModule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109213] Re: Using package functions in Manipulate/DynamicModule
  • From: Rui <rui.rojo at gmail.com>
  • Date: Sat, 17 Apr 2010 06:04:35 -0400 (EDT)
  • References: <hq0mqd$k0u$1@smc.vnet.net> <hq3a6s$ndh$1@smc.vnet.net>

On Apr 13, 11:44 pm, Albert Retey <a... at gmx-topmail.de> wrote:
> Hi,
>
> > 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)
> > Manipulate[
> > 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)
>
> I think your problem are namespaces and the time when symbols are
> created: When the Manipulate is seen, the variables IListPlot and SS
> will be created as variables in the Global` context, and only afterwards
> the package is loaded, creating the same variables in the
> AddOns`-Context. To prevent this there are several ways, one of the most
> straightforward would be to use explicitly the full long names of the
> symbols, that is (presumably) AddOns`IListPlot and AddOns`SS. There are
> several other possibilities, like only creating the symbols when the
> body is evaluated with something like:
>
> Symbol["IListPlot"][Symbol["SS"][p, 100] @@ Range[100]]
>
> for your ultimate goal to include everything in one notebook there seem
> to be solutions, but I don't know of anything "simple"...
>
> hth,
>
> albert

Yeah, true. But that issue solved itself when I made sure I had called
Needs["AddOns`"] befoore calling the Manipulate.
I had just assumed that since I expected Mathematica to evaluate the
Initializatoin part befooore the Manipulate expression, I'd had no
trouble. But now I guess that even when Mathematica doesn't evaluate
something, it still translates the symbols to the full context as soon
as it can. Not sure, hehe


  • Prev by Date: Re: Creating a hybrid cell
  • Next by Date: Re: Pade Approximation (further generalizations?---feature request)
  • Previous by thread: Using package functions in Manipulate/DynamicModule
  • Next by thread: Re: Using package functions in Manipulate/DynamicModule