I have a list of variables (c1
,c2
,c3
,c4
), each with its own range of possible values and each being a possible control.
I need to pick two of them and make the remaining ones controls in a DynamicModule
. I tried to use suggestions from here but I didn't mange to make the last step work.
DynamicModule[{allC, lC, fC, sC},
allC = {{{c1, 1, "c1"}, {1, 2}}, {{c2, 10, "c2"}, {10, 20}},
{{c3, 100, "c3"}, {100, 200}}, {{c4, 1000, "c4"}, {1000, 2000}}};
lC = Range[Length[allC]];
With[{controlGenerate = Function[{var, initialValue, str, range},
Control[{{var, initialValue, str}, range}], HoldAll]},
Column[{controlGenerate[fC, 1, "First", lC],
controlGenerate[sC, 2, "Second", DeleteCases[lC, _?(MemberQ[{fC}, #] &)]],
(* The line below works as I expected *)
Dynamic@allC[[DeleteCases[lC,_?(MemberQ[{fC,sC},#] &)]]],
(* The line below doesn't work as I intended *)
(controlGenerate[#[[1, 1]], #[[1, 2]], #[[1, 3]], #[[2]]] & /@
(allC[[DeleteCases[lC, _?(MemberQ[{fC, sC}, #] &)]]]))
}
]
]
]
(controlGenerate[...]&/@...) /. p_Part :> With[{eval = p}, eval /; True]
. $\endgroup$DynamicModule
. $\endgroup$