I want to allow users to enter some parametrized plots, using the variable t. I want the variable t to be localized to a DynamicModule so that it can't be interfered with by other things running in Mathematica. I've wrote what I was hoping would work. However when I initialize my px and py use the variable FE`t$$618 instead of t. Then when I switch between Plots the values brought up for px and py also show this FE`t$$618 to the user. How can I get around this?
DynamicModule[{names, plots, Pn, Po, t, tplot},
{{names = {"s1", "s2", "s3"},
plots = {{-2 Sin[t], 2 + 2 Cos[t]}, {Sin[t], Cos[t]}, {3 Sin[t],
4 Cos[t]}}
},
Manipulate[{{
Pn = plot,
If[Pn == Po,
{(*no change in plot selected, update parameter values*)
With[{
pn = ReleaseHold[{px, py} /.
HoldPattern[t_ /; MatchQ[t, Symbol["t"]]] :> tplot]
}, {
plots[[plot]] = pn
}
]
},
{(*change in plot selected, update manipulators*)
{px, py} = plots[[plot]]/.tplot->t(*this is the problem line of code. I want to replace tplot with the symbol t, but it ends up as t$$SomeNumbers*)
}],
Po = plot
},
Grid[{{plots}}]
}[[2]],
{{plot, 1},
Dynamic[Array[# -> ToString[names[[#]]] &, Length[plots]]],
ControlType -> PopupMenu},
{{px, -2 Sin[t],
"\!\(\*SubscriptBox[\(S\), \(x\)]\)(t)"},InputField[#, Hold[Expression]] &},
{{py, 2 + 2 Cos[t],
"\!\(\*SubscriptBox[\(S\), \(y\)]\)(t)"},InputField[#, Hold[Expression]] &}
]
}[[2]]]


tis localized byDynamicModule[], it is localized when theDynamicModuleis instantiated by the Front End. Every time an instance of the module is created, a new localization is created. Mathematica localizes the symbol-name variable by adding$$and a serial number; it is created in theFE`context and not theGlobal`one. What you're seeing is the symbol used to localize the nominal variablet. $\endgroup$List({}) instead ofCompoundExpression[](;) in some places. LikeDynamicModule[{..}, init1; init2;...; Manipulate[...]]. It's not the problem though. $\endgroup$