Re: How to find which variable caused the trigger in Manipulate[]

*To*: mathgroup at smc.vnet.net*Subject*: [mg104149] Re: How to find which variable caused the trigger in Manipulate[]*From*: "Nasser M. Abbasi" <nma at 12000.org>*Date*: Wed, 21 Oct 2009 06:29:32 -0400 (EDT)*References*: <2009102062036.015058@jfultz2winlap>*Reply-to*: "Nasser M. Abbasi" <nma at 12000.org>

> Manipulate[Row[{ > Dynamic[Refresh[r = x; "", TrackedSymbols -> {x}]], > Dynamic[Refresh[r = y; "", TrackedSymbols -> {y}]], > Dynamic[Refresh[Text[r], TrackedSymbols -> {y, x}]]} > ], > {x, 0, 1, 0.01}, > {y, 0, 1, 0.01}, > {r, "", "", ControlType -> None} > ] .... >>>> "John Fultz" wrote in message "I can't reproduce this. In 7.0.0 and 7.0.1, your example perfectly remembers for me both the values of x and y, setting the sliders at exactly the right point upon reloading. Perhaps what you meant is that it's not remembering the value of *r* after you move the x slider, save, and reload." Yes, sorry John I was not too clear. Yes, that is what I meant. The "x" slide position does remain in the same position as before closing, BUT what is displayed in the Manipulate output is NOT what was there just before closing the notebook (which was the value of the current "x" slider). This is becuase what is being displayed comes from "r" now "x", and "r" is being refreshed each time the notebook is reopened. "It does properly store the value of r, but once you reload the notebook, all of the Dynamics compute again. Since computing the Dynamics has the side effect of setting r, the stored value of r will get wiped out." Yes, but the problem is that "r" is what gets displayed, hence the display does change when closing/opening the notebook, and this is the problem. The Display as well as the slides positions should remain the same as before closing the notebook. This is a demo requirments. This is what happens with Manipulate without using Dynamics[Refresh[...]]] so I was trying to get this to behave the same way. " This amounts to the same problem as I mentioned in my first response...in this example, whether r is initially set to the value of x or y is undefined." Yes, you are correct, I see your point more clearly now. This is the _main_ problem. " It's undefined because there's nothing in the Mathematica documentation which guarantees the order in which the Dynamics are evaluated. This is true both when you initially create it, and also when you load it again from disk (or copy and paste it, as well). It so happens that it's evaluating Dynamics left-to-right in the Row, but that's not behavior you should count on. So the setting of r (if that is, indeed, what you're seeing) is within the designed behavior, and not a bug." Ok. But now I need to find a way to fix this if I want to have the same GUI design as is. I need to way to have "r" have the same value as it was before closing the notebook. Else, this whole approach will not work. I think there is some limitation here. I tried many trick to see if I can save "r" value somewhere and use a flag and such, I am still looking at it. I needed a way to be able to detect which slider is being moved each time, and at the same time, when the user closes the notebook and reopen it, the sliders and the display to be restored to the same state as before closing the notebook. The above 2 requirements seem not to be possible to achieve with the current Dynamic[Refresh[...]] solution due to the undefined order of Dynamic evaluation. Oh, well, back to the drawing board. I could always go back to my old solution of using flags to remember the state from. But your solution above was much better, except for this one problem of how to restore "r" to its old value before closing. Thanks for your help John --Nasser

**Re: Question on Dynamic with "DockedCell"**

**Re: Question on Dynamic with "DockedCell"**

**Re: How to find which variable caused the trigger in Manipulate[]**

**Re: Re: How to find which variable caused the trigger in Manipulate[]**