Re: Default value for Dynamic InputField
- To: mathgroup at smc.vnet.net
- Subject: [mg83332] Re: Default value for Dynamic InputField
- From: m.r at inbox.ru
- Date: Sat, 17 Nov 2007 05:34:01 -0500 (EST)
- References: <fhh7ku$8r4$1@smc.vnet.net>
On Nov 15, 4:39 am, robert prince-wright
<robertprincewri... at yahoo.com> wrote:
> Can someone tell me how to set default values for Dynamic input fields: I have tried Initialization with no success.
>
> Here is the generic code:
>
> InputField[ Dynamic[ R0] ]
>
> The intent is to assign a default value to the symbol R0 so that gets assigned each time the notebook is opened. The code below does not work for me!
>
> InputField[ Dynamic[ R0, Initialization:-> (R0=123)] ]
>
> Thanks
> Robert
This is an issue with the initialization of Dynamic. As a workaround,
you can use DynamicModule's Initialization:
DynamicModule[{},
InputField[Dynamic[R0]],
Initialization :> (R0 = 123)]
This will correctly set the global R0 to 123 if you e.g. save the
notebook, close and then reopen it.
Maxim Rytin
m.r at inbox.ru