I apologise for the initial post, but it surprised me that the evaluation worked! Ok so here is a fuller code. I do get inconsistent results with this but it seems simple enough that a button should be able to execute a user defined function
relevant functions are buildCoords test2 and test 3
a typical output when each button is pressed is
test 1 : buildCoords[60,60,60,60,120,0,0]
test 2: test2[60,60,60,60,120,0,0]
test 3: 120
buttons test 1 and test 2 display current parameter values but does not evaluate the function
test 3 which is a simple calculation works
Is this a bug, or is there some initialisation issue or complexity limit
the code
fx [i, j, d, v, h, t, w, x0] :=
i (1 - d Sin[v]) Cos[v] Sin[h] Sin[t] -
j (1 - dSin[v]) Cos[v] Cos[h] Cos[t] +
wLog[2 - Sin[v]](-Sin[t] + Cos[t]) + x0;
fy [i, j, d, v, h, t, w, y0] :=
i (1 - d Sin[v]) Cos[v] Sin[h] Cos[t] +
j (1 - dSin[v]) Cos[v] Cos[h] Sin[t] +
wLog[2 - Sin[v]](Cos[t] + Sin[t]) + y0;
fz[k, v, z0_] :=
k (1 - Sin[v])/2 + z0;
fR[x, y, z_] := Sqrt[x^2 + y^2 + z^2];
fL[x, y] := ArcTan[y/x];
fB[x, y, z_] := ArcSin[z/Sqrt[x^2 + y^2 + z^2]];
cart2gal[FB_] := Module[ {fbD4},
fbD1 = Dataset[TableForm[<a href="mailto:InputForm@FB]]">InputForm@FB]];
fbD2 = fbD1[All, <| "x" -> 1, "y" -> 2, "z" -> 3 |>];
fbD3 = fbD2[
All, # ~Join~ <| "R" -> Sqrt[#x^2 + #y^2 + #z^2],
"L" -> ArcTan[#y/#x],
"B" -> ArcSin[#z/Sqrt[#x^2 + #y^2 + #z^2]] |> &];
fbD4 = fbD3;
]
test2[np, nq, i, j, k, d, t, w] := Module[{arr},
arr = {{"x", "y", "z", "R", "L", "B", "Ldeg", "Bdeg", "h", "v"}};
arr = Join[arr, {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}];
]
test3[a, b] := a + b;
buildCoords[np, nq, i, j, k, d, t, w] := Module[{arr},
pi = 3.14159265358979;
hstep = pi/(nq - 1);
vstep = 2*hstep;
xdist = 85;
arr = {{"x", "y", "z", "R", "L", "B", "Ldeg", "Bdeg", "h", "v"}};
v = 0.01;
h = -2;
y = fy[i, j, d, v, h, t, w, 0];
z = fz[k, v, 0];
R = fR[x, y, z];
L = fL[x, y];
B = fB[x, y, z];
dL = r2d[L];
dB = r2d[B];
arr = Join[arr, {{x, y, z, R, L, B, dL, dB, h, v}}];
]
cart[FB_] := TableForm[(InputForm@FB)[[1, 1, 1]]];
r2d[r_] := N[r*180/Pi];
Manipulate[
FB = ParametricPlot3D[{
fx [i, j, d, v, h, t, w, 0],
fy [i, j, d, v, h, t, w, 0],
fz[k, v, 0]},
{v, 0, 2 [Pi]},
{h, -[Pi]/2 , [Pi]/2},
ViewPoint -> Dynamic@vp,
Mesh -> Automatic,
MeshStyle -> mcolor,
PlotStyle -> scolor,
AspectRatio -> 1],
Row[{Text[
"L, the y axis (horizontal) and B, the Z axis (vertical)\n are \
in approximate degrees as observed from the Sun.\nThe default \
parameter set best matches the bubble shape without the 'wind' \
effect"]}],
{{i, 60, "L ~y axis (i)"}, 5, 160, Appearance -> "Labeled"},
{{j, 60, "To GC ~x axis (j)"}, 5, 160, Appearance -> "Labeled"},
{{k, 120, "B ~z axis (k)" }, 5, 160, Appearance -> "Labeled"},
{{d, 0.2, "Thinness (d)"}, 0, 1, Appearance -> "Labeled"},
{{t, 0, "xy Tilt (t)"}, -Pi/2, Pi/2, Appearance -> "Labeled"},
{{w, 0, "'Wind' factor (w)"}, -20, 20, Appearance -> "Labeled"},
{{vp, {0, -85, 0}, "View Point"},
{{5, 8, 4} -> "xyz", {0, -85, 0} ->
"yz (from Sun)", {0, 0, Infinity} -> "yx", {Infinity, 0, 0} ->
"xz"}, PopupMenu},
{{mcolor, RGBColor[0., 1.
, 0.07`], "Mesh"}, ColorSlider},
{{scolor, RGBColor[255, 72, 255], "Surface"}, ColorSlider},
Delimiter,
Row[{Spacer[100],
Button["Test 1",
Print[Evaluate[buildCoords[60, 60, i, j, k, t, w]]],
Method -> "Queued", ImageSize -> 100]}],
Row[{Spacer[100],
Button["Test 2", Print[Evaluate[test2[60, 60, i, j, k, t, w]]],
Method -> "Queued", ImageSize -> 100]}],
Row[{Spacer[100],
Button["Test 3", Print[Evaluate[test3[i, j]]], Method -> "Queued",
ImageSize -> 100]}],
Row[{Spacer[100],
Button["Reset",
FrontEndExecute[FrontEndToken["EvaluateNotebook"]],
ImageSize -> 100]}]
]