# Manipulate variables with dependencies

I have the following, simplified program:

import = {{"one", 1, 2, 3}, {"two", 4, 5}, {"three", 6, 7, 8, 9}};

Manipulate[
s = Select[import, MemberQ[#, e] &];
calc,
{e, {"one", "two", "three"}},
{calc, Rest[s[[1]]]}
]


The second setterbar displays numbers. Now, when clicking e.g. "two" in the first setterbar, I'd like that in the second setterbar the numbers update to 4 and 5. Then when clicking e.g. "three" in the first setter bar, the second setter bar updates to 6 7 8 9, and so on. The s is a much larger and more complex imported file, and the 'calc' is a more complex operation, but this should outline the principle – and basic problem.

• I think not really. The critical point is, that when clicking e.g. "one" in the first setterbar, the second setterbar should update to '4 5' which seems not doable with TrackingFunction (I think). – Mockup Dungeon Dec 7 '16 at 9:32
• I see, something like: mathematica.stackexchange.com/q/33402/5478 – Kuba Dec 7 '16 at 10:03

I think you want to use ControlType to fix the type of controller, and I would suggest using an Association to quickly select the values, like this:

(*Association of e to calc values*)
import = <|"one" -> {1, 2, 3}, "two" -> {4, 5}, "three" -> {6, 7, 8, 9}|>;

Manipulate[
s = Select[import, MemberQ[#, e] &];
calc,

{e, {"one", "two", "three"}},
(*Here we make calc depend on the value of e by just using it in the variable spec*)
{calc, import[e], ControlType -> TogglerBar}
]


• Great! Thanks a lot. – Mockup Dungeon Dec 7 '16 at 17:51