MathGroup Archive 2008

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

Search the Archive

Re: Run initialization cells before dynamic cells

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94264] Re: Run initialization cells before dynamic cells
  • From: "sjoerd.c.devries at gmail.com" <sjoerd.c.devries at gmail.com>
  • Date: Tue, 9 Dec 2008 06:59:37 -0500 (EST)
  • References: <ghj04h$fhn$1@smc.vnet.net>

Damen,

You could add SaveDefinitions->True to your Manipulate. If you then
run and save your notebook all necessary definitions are stored in the
Manipulate object.

As a demonstration try the following example:

f[x_, y_] := x^y;

Manipulate[Plot[f[k, j] , {k, 1, 10}], {j, 1, 10},  SaveDefinitions ->
True]

Next time you open the notebook the Manipulate will be as you left it
the last time you saved the file.

Cheers -- Sjoerd

On Dec 8, 1:24 pm, Damon <damonwisc... at gmail.com> wrote:
> I have a notebook in which I define lots of useful computations, then
> I have a few Manipulate or other Dynamic cells to illustrate those
> computations.
>
> When I open the notebook, the Dynamic cells do not run properly
> because the computations on which they depend have not been defined. I
> tried marking the definitions as Initialization cells, but they are
> still not executed before the Dynamic cells. (I open the notebook, I
> get the "Dynamic Content" warning, I tell it to go ahead and display
> the dynamic content, then the Dynamic cells are not displayed properly
> because the initialization cells have not been run; later, when I
> first try to execute a cell, I am shown the "Initialize Notebook?"
> dialog, and I tell it to execute all initialization cells; finally,
> all the content displays properly.)
>
> The demos that I've looked at from wolfram.com all have single
> Manipulate cells, which define inside them all the initialization
> material. This isn't appropriate for me, because I have many different
> Dynamic cells which all depend on the same definitions.
>
> I tried adding this to my Dynamic cells:
>
> Dynamic[CleverDisplay[...], Initialization :> FrontEndExecute
> [FrontEndToken["EvaluateInitialization"]] ]
>
> but (a) it doesn't work, i.e. the initialization cells are not
> evaluated until I shift+enter to evaluate some cell in the notebook,
> and (b) if I have several of these, I'm worried it will try to execute
> the initialization cells several times.
>
> I must just be doing this the wrong way. Any advice?
>
> Damon.



  • Prev by Date: Re: Clever Tricky Solutions
  • Next by Date: Re: Drop elements from list
  • Previous by thread: Re: Run initialization cells before dynamic cells
  • Next by thread: Re: Run initialization cells before dynamic cells