I'm creating a data table script using New Script() that needs to be evaluated later when a user clicks it. I need to substitute some variables at script-creation time (like a file path) while preserving Expr() calls that should only be evaluated when the script actually runs.
file_path = "C:\MyData\slopes.jmp";
dt << New Script("Plot Slopes",
dt_slopes = Open( file_path );
slope_array = dt_slopes:slope << Get Values;
nw = New Window( "Slope Plots",
gb = Graph Box()
);
framebox = gb[Frame Box(1)];
For Each( {slope}, slope_array,
Eval( Eval Expr(
framebox << Add Graphics Script(
Y Function( Expr(slope) * x, x );
);
));
);
);
The problem: I need file_path to be evaluated and inserted as a literal string when creating the script, but the Expr(slope) inside the For Each loop must remain unevaluated until the script runs (when the user clicks it).
If I wrap everything in Eval(Eval Expr()) to substitute file_path, it also evaluates Expr(slope)prematurely, causing an error since slope doesn't exist yet.
What's the correct approach to selectively evaluate some variables while preserving others for deferred evaluation in stored data table scripts?