Dependent dynamic controls

*To*: mathgroup at smc.vnet.net*Subject*: [mg100367] Dependent dynamic controls*From*: replicatorzed at gmail.com*Date*: Tue, 2 Jun 2009 06:42:01 -0400 (EDT)

Dear Group, I have a set of dynamic controls that should control a complicated program (omitted here). The following code works partially: initialization is not performed correctly, but afterwards everything runs as expected: aSet = {"a1", "a2", "a3"}; bSet = {"b1", "b2", "b3"}; Module[{sw = True, a, b, c, n, assign}, assign[switch_, x_] := If[switch, a = x; c = f@x; n = Position[aSet, x][[1, 1]];, b = x; c = g@x; n = Position[bSet, x][[1, 1]]]; (* Initialize *) assign[sw, First@If[sw, aSet, bSet]]; Dynamic@Panel@Column@{ (* Output *) Column@{sw, If[sw, a, b], c, n}, (* Controls *) Grid[{ {"a", RadioButton[Dynamic[sw, (sw = #; assign[#, First@aSet]) &], True], PopupMenu[Dynamic[a, assign[sw, #] &], aSet, Enabled -> sw]}, {"b", RadioButton[Dynamic[sw, (sw = #; assign[#, First@bSet]) &], False], PopupMenu[Dynamic[b, assign[sw, #] &], bSet, Enabled -> ! sw]} }] } ] The problem is after running the code a and b are not assigned their correct values, while after startup switching between a and b by the radiobutton, and switching values for a and b via the popupmenus work correctly. The code above is almost identical to the method used by David Park (at least three examples were posted: http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/f225f6342f46cc54/39c6c0ee239a5dae?hl=en%27c6c0ee239a5dae http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/1604b1813288a377/cfa5cc0ef26aeb46?hl=en&#cfa5cc0ef26aeb46 http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/79b7031223805d0d/2ddd4ac0155a3d7f?hl=en%02ddd4ac0155a3d7f&fwc=2 Although with the introduction of the switch variable 'sw', dependencies do not initialize normally. Any idea how to overcome this? Istvan Zachar