It is possible to calculate them inside. If there is a possibility that they change between different table script runs, they should be inside it otherwise I would move them outside and evaluate the value inside the script.
Generally, I would always avoid using EvilParse (Eval(Parse()) as it is a nightmare to debug and, in my opinion, there is almost never a reason to use it. This does look complicated, but I would approach this with something like this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Label Offset has very annoying format to build as it isn't list with lists
// but just something with lists
table_script = Expr(
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
Eval(Substitute(
Expr(Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{_labeloffset_,
Set Force Labels("Label by Row")}
)}
)
)
)),
Expr(_labeloffset_), Name Expr(offsets)
));
);
Eval(EvalExpr(
dt << New Script("test script",
Expr(Name Expr(table_script));
);
));
You could also move the Label Offset outside of graph builder and send the message to the graph builder after it has been built (I'm not sure if this sets Set Force Labels correctly)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Label Offset has very annoying format to build as it isn't list with lists
// but just something with lists
table_script = Expr(
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
gb = Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{Set Force Labels("Label by Row")}
)}
)
)
);
ms = Report(gb)[FrameBox(1)] << Find Seg(MarkerSeg(1));
Eval(EvalExpr(Send(ms, Expr(Name Expr(offsets)))));
wait(0);
);
Eval(EvalExpr(
dt << New Script("test script",
Expr(Name Expr(table_script));
);
));
The final table script should look like this
Names Default To Here(1);
Rows = Current Data Table() << get rows where(:Sex == "F");
offsets = Expr(Label Offset());
For Each({row, idx}, Rows,
WeightValue = :weight[row];
HeightValue = :height[row];
l = Eval List({row - 1, -5, 12, WeightValue, HeightValue});
Insert Into(offsets, l);
);
gb = Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(Marker Seg(1), {Set Force Labels("Label by Row")})}
)
)
);
ms = Report(gb)[FrameBox(1)] << Find Seg(Marker Seg(1));
Eval(Eval Expr(ms << Expr(Name Expr(offsets))));
Wait(0);
and the script you get from graph builder
Graph Builder(
Size(528, 456),
Show Control Panel(0),
Variables(X(:weight), Y(:height)),
Elements(Points(X, Y, Legend(5))),
SendToReport(
Dispatch({}, "Graph Builder", FrameBox,
{DispatchSeg(
Marker Seg(1),
{Label Offset(
{8, -5, 12, 112, 60},
{0, -5, 12, 95, 59},
{9, -5, 12, 107, 61},
{1, -5, 12, 123, 61},
{10, -5, 12, 67, 56},
{2, -5, 12, 74, 55},
{3, -5, 12, 145, 66},
{4, -5, 12, 64, 52},
{15, -5, 12, 81, 61},
{16, -5, 12, 91, 62},
{17, -5, 12, 142, 65},
{18, -5, 12, 84, 63},
{19, -5, 12, 85, 62},
{27, -5, 12, 92, 62},
{28, -5, 12, 112, 64},
{34, -5, 12, 112, 65},
{35, -5, 12, 115, 60},
{37, -5, 12, 116, 62}
), Set Force Labels("Label by Row")}
)}
)
)
);
-Jarmo