# How to control variables of outer and inner Manipulates?

Consider the following ( working ) snippet:

  Manipulate[
Column[{
Manipulate[
vote,
{vote, {"Yes", "No"}},
],
k,
}],
{k, 1, 5, .5}
]


My question concerns programming style and Outer/Inner Manipulate structures. What is the best way to handle code that is executed conditionally based on values in the inner Manipulate, but needs to be processed further in the outer Manipulate? I.e. checking thresholds, maintaining sub-totals, balancing, etc.

To make my question 'answerable' I have translated it in terms of a simplified example: how / where would you maintain a Yes vote counter that is used in the outer manipulate?

UPDATE: The requested pattern would also apply to synchronizing views in data on Tabs on a TabView.

-
I edited the title to better reflect the actual problem here, please feel free to revert/change if you think it is not correct. –  István Zachar Apr 30 '12 at 12:51

The outer Manipulate defines a list (voteList) for tracking all votes (thus I used integer values for k), and the inner Manipulate is using the actual value of the kth vote for the definition of vote. If the inner Yes/No setter is changed, it changes vote, voteList and the number of votes as well, due to the pure controlfunction SetterBar. I also moved the initialization code to the outer Manipulate, as votes should be local to the whole thing, not just the inner Manipulate.

Manipulate[Column[{
Manipulate[
vote,
{{vote, voteList[[k]]}, {True, False},
SetterBar[
Dynamic[vote, (vote = #; voteList[[k]] = #;
votes = Total@Boole@voteList) &], {True -> "Yes",
False -> "No"}] &}
],
(*voteList,*)

Of course in this example of yours there is no need to wrap the internal vote into Manipulate, but I guess that this was just a toy example of a more complex problem. I'm not sure my solution is eaxactly the thing you are looking for, but if you provide some feedback, I can modify the code to better fit your requirements.