# Getting arrays of values out of Manipulate

More about getting variables out of Manipulate:

If I execute the following:

Manipulate[{xb1, xb2, xb3},
{xb1, 0, 1},
{xb2, 0, 1},
{xb3, 0, 1},
LocalizeVariables -> False]


I get 3 sliders and the list {0,0,0}. If I ask for the value of xb1, I get 0.

If I execute the similar form:

Manipulate[{xb[1], xb[2], xb[3]},
{xb[1], 0, 1},
{xb[2], 0,  1},
{xb[3], 0, 1},
LocalizeVariables -> False]


I get $3$ sliders and the list {0,0,0}. HOWEVER, if I ask for the value of xb[1], I just get xb[1]. Why? LocalizeVariables->False seems not to work in this case.

More importantly, how can I get a list of the values of the Manipulate variables as Global variables?

The actual case I'm using has multiple lists of Locator variables, which seems to be even more difficult to get at than, say, multiple lists of Slider variables.

inputgraphs[inputrangex_List,
inputrangey_List,
name_String, indexnumber_] :=
DynamicModule[{
pts = {{0, 0}, {inputrangex[[2]]/4, 0}, {inputrangex[[2]]/2, 0},
{3 inputrangex[[2]]/4, 0}, {inputrangex[[2]], 0}},
locatoricon},
locatoricon =
Graphics[{Red, PointSize[Medium], Point[{0, 0}]}, ImageSize -> 18];
Column[{
LocatorPane[Dynamic[pts],
Dynamic[Plot[
InterpolatingPolynomial[pts, x], {x, 0, inputrangex[[2]]},
PlotRange -> {inputrangex, inputrangey}, Frame -> True,
ImageSize -> Medium, Axes -> True, FrameLabel -> name]],
Appearance -> locatoricon, LocatorAutoCreate -> True],
Button["Save", With[{p = pts}, points = p]]}]]


I would like to have used the argument indexnumber to be an index for each use of manipulate variables (one for each graph), but that doesn't work, probably because for the same reason the example using indexed variables in Manipulate given above doesn't work.

-
Maybe because xb[1] is not a Symbol and LocalizeVariables->False does not affect it. Just a guess... –  Kuba Nov 29 '13 at 19:09
@Kuba is correct. You need to be using symbols. This would also fail for the same reason if you tried TrackSymbols for some dynamic operation –  Mike Honeychurch Nov 29 '13 at 23:07

The simplest way to capture a list of values in a global variable is to assign that variable directly, e.g.:

Manipulate[
xb = {xb1, xb2, xb3}
, {xb1, 0, 1}
, {xb2, 0, 1}
, {xb3, 0, 1}
]


In this example, xb1, xb2 and xb3 are kept localized to the Manipulate, but xb is global.

-