Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: What is the point of having Initializations in DynamicModule and Manipulate?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123153] Re: What is the point of having Initializations in DynamicModule and Manipulate?
  • From: John Fultz <jfultz at wolfram.com>
  • Date: Thu, 24 Nov 2011 07:00:22 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Reply-to: jfultz at wolfram.com

On Wed, 23 Nov 2011 07:07:54 -0500 (EST), Nasser M. Abbasi wrote:
> On 11/22/2011 4:43 AM, Armand Tamzarian wrote:
>
>>
>> that was what I expected. whereas
>>
>> In[]=ClearAll[g];
>> DynamicModule[{},
>> g,
>> Initialization :> {g = "hello world"}]
>>
>> Out[]= g
>>
>> this is not what I expected because I thought the initialization would
>> establish the global value of g and therefore that value would be
>> *displayed*. (I do not expect g to dynamically update. How can it?)
>>
>
> Hi;
>
> If you change :> to -> then you get the output you want:
>
> ---- cell one ---------------
> In[9]:= ClearAll[g];
> -------------------------
>
> ------- cell 2 ---------------------
> In[10]:= DynamicModule[{},g,Initialization->{g="hello world"}]
> ------------------------------------
>
> Out[10]= hello world
>
> Not sure though if this is a solution that you could use
> for your main work, but just wanted to point this out.
>
> --Nasser

This is a bad solution, though, because it will not properly initialize 'g' in 
future sessions.  As I mentioned in another post that came through last evening, 
using Rule[] in the Initialization option virtually never does what you want, 
and is always ill-advised.

Sincerely,

John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.



  • Prev by Date: Contours for negative and positive in ContourPlot
  • Next by Date: Color discontinuity with ColorFunction in ContourPlot
  • Previous by thread: Re: What is the point of having Initializations in DynamicModule and Manipulate?
  • Next by thread: Re: What is the point of having Initializations in DynamicModule and Manipulate?