Re: Initialization problem in a DynamicModule
- To: mathgroup at smc.vnet.net
- Subject: [mg106671] Re: Initialization problem in a DynamicModule
- From: István <replicatorzed at gmail.com>
- Date: Wed, 20 Jan 2010 06:51:58 -0500 (EST)
- References: <hj40pp$sgd$1@smc.vnet.net>
Thank you for the extensive help. For those who are interested, and could not see the replies I got (*OFF* I still don't understand fully the posting behaviour of this interface: I got at least 4 emails, but none of them shows up in the web interface. If I reply to the emails, then I assume no post will show up in the group's archive. Therefore I always post using the web inteface. Is there a better way to do this? *ON*), I will recapitulate the solution. The "assign" and "initialize" functions should be defined with DownValues instead of OwnValues, that is: assign[]:=(...) instead of assign:=(...), although the fact that simply OwnValues won't work here goes against my intuition. Also it is not clear (although Ariel shed some light on it) what is the exact difference between calling the functions assign [] and initialize[] at the end of the Initialization option or at the start of DynamicModule, right after defining local variables: DynamicModule[{assign,x,y},(*dynamic expression to show*),Initialization:>(assign[]:=(y=x);assign[]a)] vs. DynamicModule[{assign,x,y},assign[];(*dynamic expression to show*),Initialization:>(assign[]:=(y=x))] Furthermore, Norbert has pointed out, that my model can be further simlified to this: DynamicModule[{something},1,Initialization:>(something:=(Print["you should never see this!"]);)] returning 1, and the string is printed as well, which effectively demonstrates, that DynamicModule evaluates even those expressions, which shouldn't be evaluated. Unfortunately, this example, and the following one (still from Norbert) completely freezes my Mathematica 7.0 (I have to kill it from TaskManager), so I can't even confirm. Anyone else has problems evaluating these examples, or you all can run them as Norbert does? DynamicModule[{x=False,something,i=0},{ RadioButton[Dynamic[x,(x=#)&],True], RadioButton[Dynamic[x],False], Dynamic[i]}, Initialization:>(something:=(Print["init",i++]))
- Follow-Ups:
- Re: Re: Initialization problem in a DynamicModule
- From: Ariel Sepulveda <sepulveda.cuevas@gmail.com>
- Re: Re: Initialization problem in a DynamicModule