Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Re: Initialization problem in a DynamicModule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106715] Re: [mg106671] Re: Initialization problem in a DynamicModule
  • From: Ariel Sepulveda <sepulveda.cuevas at gmail.com>
  • Date: Thu, 21 Jan 2010 04:57:31 -0500 (EST)
  • References: <hj40pp$sgd$1@smc.vnet.net> <201001201151.GAA09530@smc.vnet.net>

Itsvan:

Assigning values inside Initializaiton causes the DynamicModule to change
last session values with initialization values.  My opinion is that this is
not wrong but is not what is intended/expected from DynamicModule.  You can
try creating both cases and then comparing behavior after quitting Kernel.

Ariel

On Wed, Jan 20, 2010 at 7:51 AM, Istv=E1n <replicatorzed at gmail.com> wrote:

> 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++]))
>
>


--
Ariel Sepulveda, Ph.D.
__________________________
President, Pronto Analytics Inc.
Tel. 787.354.6947
ariel.sepulveda at prontoanalytics.com
http://www.prontoanalytics.com



  • Prev by Date: Re: simple nest
  • Next by Date: Re: Sorting paired columns of dates and values
  • Previous by thread: Re: Initialization problem in a DynamicModule
  • Next by thread: Re: Initialization problem in a DynamicModule