Wie kann man Variablen in New Script() selektiv auswerten und gleichzeitig Expr() für die verzögerte Auswertung beibehalten?Ich erstelle ein Datentabellenskript mitNew Script()das muss später ausgewertet werden, wenn ein Benutzer darauf klickt. Ich muss einige Variablen bei der Skripterstellung ersetzen (z. B. einen Dateipfad) und dabei Folgendes beibehalten:Expr()Aufrufe, die nur ausgewertet werden sollen, wenn das Skript tatsächlich ausgeführt wird.
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 );
);
));
);
);
Das 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.
Was ist der richtige Ansatz, um einige Variablen selektiv auszuwerten und andere für die verzögerte Auswertung in gespeicherten Datentabellenskripten beizubehalten?
Automatisierung und SkriptingBetreff: Wie kann ich Variablen in New Script() selektiv auswerten und gleichzeitig Expr() für die verzögerte Auswertung beibehalten?Eine Möglichkeit besteht darin, Ihrem Code etwas Expr(Name Expr()) hinzuzufügen.
Names Default To Here(1);
file_path = "C:\MyData\slopes.jmp";
Eval(EvalExpr(
dt << New Script(
"Plot Slopes",
dt_slopes = Open(Expr(file_path));
slope_array = dt_slopes:slope << Get Values;
nw = New Window("Slope Plots", gb = Graph Box());
framebox = gb[Frame Box(1)];
Expr(Name Expr(For Each({slope}, slope_array,
Eval(Eval Expr(framebox << Add Graphics Script(Y Function(Expr(slope) * x, x))))
)));
);
));
Wenn Sie nur den EvalExpr-Teil ausführen, erhalten Sie das folgende Skript
dt << New Script(
"Plot Slopes",
dt_slopes = Open("C:\MyData\slopes.jmp");
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))
)
)
);
)

Betreff: Wie kann ich Variablen in New Script() selektiv auswerten und gleichzeitig Expr() für die verzögerte Auswertung beibehalten?netter Trick:
Ausdruck(Name Ausdruck()) als Synonym für schützen()
vielleicht hier abstimmen:
2 Funktionen für die 2 Bedeutungen von expr()