Initialization of a dynamic module
- To: mathgroup at smc.vnet.net
- Subject: [mg89869] Initialization of a dynamic module
- From: Hannes Kessler <HannesKessler at hushmail.com>
- Date: Mon, 23 Jun 2008 02:48:10 -0400 (EDT)
Hello,
I have a problem with an incorrect context and context path after
loading a dynamic module initialized with Needs.
Consider the following example:
1. Execute the code given below in a fresh notebook. The dynamic
elements work as expected.
2. Save and re-open the notebook. The dynamic elements still work as
expected.
However, a check of $ContextPath and $Context gives {"Units`",
"System`"} and Units`.
The Global` context disappeared, and new symbols will be created in
the Units` context.
Here is the code:
Needs["Units`"];
DynamicModule[{a = 10 Newton},
{
PopupMenu[Dynamic @ a, {10 Newton, 20 Newton}],
Refresh[Dynamic @ a, TrackedSymbols -> {a}],
Context @ Newton
},
Initialization :> Needs["Units`"]]
How the dynamic module has to be modified in order to recover a normal
state with Global` set as current context and being part of the
context path after initialization?
Best regards,
Hannes Kessler