Re: Run initialization cells before dynamic cells
- To: mathgroup at smc.vnet.net
- Subject: [mg94355] Re: Run initialization cells before dynamic cells
- From: Damon <damonwischik at gmail.com>
- Date: Thu, 11 Dec 2008 03:43:29 -0500 (EST)
- References: <ghnfih$nl3$1@smc.vnet.net>
I should have included an example file. Suppose my notebook contains f[x_] := x^2 Dynamic[f[2]] Dynamic[f[10]] If I run this the first time, I get the answer I'm expecting (it shows 4 and 100). But if I save the notebook, quit Mathematica, then restart, I see f[2] and f [10], not f[4] and f[100]. I want to know: is there any way to make Mathematica execute the definition of f before it tries to display the Dynamic cells? I tried marking the definition of f as an initialization cell, but it still tries to display the Dynamic cells before it runs the initialization cells. I wanted to use Dynamic rather than Manipulate, because Manipulate doesn't give me enough flexibility in how to place my controls -- instead I defined my own custom control panel then I used Dynamic to show the output. But because I am using Dynamic, I cannot use the SaveDefinitions option, which only works in Manipulate. I could place the definition of f inside each of the Dynamics, but it's silly to duplicate effort. Incidentally, I just discovered an answer which is sufficient for my needs. I don't actually _need_ to use Dynamic, I can use a Manipulate with no controls (given that I've defined my own control panel elsewhere). If I use Manipulate[ f[2], SaveDefinitions->True, Paneled->False, AppearanceElements->None, FrameMargin->None ] then it looks exactly how I want, and I can use the SaveDefinitions option. As a bonus, this means that the saved definitions are available for any other Dynamic[] cell in the notebook. But I still think it's crummy that Dynamic[] does not have a SaveDefinitions option. Damon.