Tracking a dynamic variable
- To: mathgroup at smc.vnet.net
- Subject: [mg88607] Tracking a dynamic variable
- From: "Matthias Gottschalk" <mgott at gfz-potsdam.de>
- Date: Fri, 9 May 2008 07:17:08 -0400 (EDT)
Hello I have a larger program in which I want to look if a value of a dynamic variable has changed. A short version of this program looks like this: Interpretation[{x = 1, y = 1, flag1 = False, flag2 = False}, TabView[{ "task 1" -> Dynamic[ Block[{}, (* store old value of x *) y = x; (* test if x changed *) If[x != y, flag1 = True]; (* display input and some outout *) Panel[ Grid[ {{ InputField[Dynamic[x]], Dynamic[x], Dynamic[y], flag1 }} ] ] ] ], "task 2" -> Dynamic[ Block[{}, If[x == y, flag2 = True, flag2 = False ]; Panel[ Grid[ {{x, y, flag1, flag2}} ] ] ] ] } ], Print["end"] ] I want to track the variable x and if it has changed in "task 1" an appropriate action should be accomplished in "task 2". The program above works only if for the input in "task 1" the Return key is not pressed in the InputField. If I press Return in the InputField the whole "task 1" is executed and then y will be equal to x in any case. Now how can I track the value of x so that I can decide in "task 2" that x has changed? Matthias