I'm doing a CDF document where I'm placing Dynamic pieces in the middle of the text. This document is supposed to work in the Player.
What is the best way to register glogal values that should be accessed from all the dynamic pieces that are scattered around different cells?
For instance, I want to define g=9.8, and I want this value to be accessed by all the dynamics that are placed in the different cells. Since this should work on the player, this value should persist across sessions of Mathematica.
I could only think of 2 different ways:
- an action button that has to be clicked by the user, when he opens the file, that launches all the needed = and := used around the notebook
- create an empty manipulate, with a SaveDefinitions->True, and whose variable are not localized to the Manipulate
Both seem too artificial.
Having any other method that only sets the definitions once it is displayed is not good, since the person that accepts to display the dynamics may have already scrolled down, and passed by the dynamic that implements all the needed definitions.
So, how to "SaveDefintions" without using the Manipulate structure?
I have not tried this in dynamics document like you have, but you can try this:
"Using initialization cells, you can specify that particular input cells of a notebook should be evaluated first. This ensures that your code is evaluated in the correct order, such as defining functions before evaluating cells that use those definitions."
http://reference.wolfram.com/mathematica/howto/WorkWithInitializationCells.html