Und hier sind einige der sehr häufigen Probleme, auf die Sie stoßen könnten, und wie Sie sie mit Ausdrücken und bei Bedarf durch Auswertung lösen können.
1. Verwendung einer Konstante in einer Formel
Problem:
Ihre Formel funktioniert nur einmal und sieht nach dem Speichern und erneuten Öffnen so aus:

Lösung:
Fügen Sie einen Ausdruck in einen anderen ein, indem Sie Eval Insert, Eval Expr, Parse und Substitute verwenden . Meistens verwende ich Eval(EvalExpr()).
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
value_to_add = 5;
Eval(EvalExpr(
dt << New Column("HeightAddFive", Numeric, Continuous, Formula(
Expr(value_to_add) + :height
));
));
2. Verwendung einer Konstante in einem Grafikskript
Problem:
Am Ende erhalten Sie ein Skript wie dieses
Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:weight), Overlay(:sex)),
Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2))),
SendToReport(
Dispatch(
{},
"Graph Builder",
FrameBox,
{Add Graphics Script(
7,
Description(""),
Pen Color(color_to_use);
Pen Size(size_to_use);
H Line(value_to_add);
)}
)
)
);
Lösung:
Verwenden Sie Eval(EvalExpr()) (oder Substitute() ist eine andere gute Option)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
value_to_add = 80;
gb = dt << Run Script("Graph Builder Smoother Line");
color_to_use = "Red";
size_to_use = 2;
Eval(EvalExpr(
Report(gb)[FrameBox(1)] << Add Graphics Script(
Pen Color(Expr(color_to_use));
Pen Size(Expr(size_to_use));
H Line(Expr(value_to_add));
);
));
3. Variablen als Spezifikationsgrenzen festlegen
Problem:
Spezifikationsgrenzen werden nicht korrekt festgelegt
Lösung:
Beginnen Sie damit, JMP den Code erstellen zu lassen (Spalteneigenschaft hinzufügen und den Code aus dem erweiterten Protokoll übernehmen oder mit der rechten Maustaste auf die Spalte klicken und „Spalteneigenschaften kopieren“ auszuwählen). Du bekommst so etwas
Data Table("Big Class"):height << Set Property(
"Spec Limits",
{LSL(11), USL(22), Target(12), Show Limits(1)}
);
Verbessern Sie dieses Skript, um Variablen zu verwenden
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
aa_specs = Associative Array();
aa_specs["height"] = ["LSL" => 50, "USL" => 80];
aa_specs["weight"] = ["LSL" => 60, "USL" => 160];
For Each({col_name}, dt << Get Column Names("String"),
If(Contains(aa_specs, col_name),
Eval(EvalExpr(
Column(dt, col_name) << Set Property("Spec Limits" ,{
LSL(Expr(aa_specs[col_name]["LSL"])),
USL(Expr(aa_specs[col_name]["USL"])),
Target(Expr((aa_specs[col_name]["LSL"] + aa_specs[col_name]["USL"])/2)),
Show Limits(1)
})
));
);
);
4. Tabellenskripte zur Tabelle hinzufügen
Problem:
Am Ende erhalten Sie ein Tabellenskript, das etwa Folgendes sagt

Lösung:
Eval(EvalExpr()) mit Name Expr(). Dadurch wird das Diagramm überhaupt nicht erstellt. Wenn Sie es ausführen möchten, verwenden Sie << Run Script("My nice graph") oder werten Sie den Ausdruck aus
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb_expr = Expr(dt << Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:weight), Overlay(:sex)),
Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2))),
));
Eval(EvalExpr(
dt << New Script("My nice graph", Expr(Name Expr(gb_expr)));
));
// dt << Run Script("My nice graph");
// Eval(gb_expr);
</CODE>aber in solchen Fällen würde ich meistens << Skript in Datentabelle speichern verwenden, aber dadurch wird die Plattform ausgeführt, also denken Sie daran, sie zu schließen</P>
<P> </P>
<PRE><CODE class=" language-jsl">Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb_expr = Expr(dt << Graph Builder(
Show Control Panel(0),
Variables(X(:height), Y(:weight), Overlay(:sex)),
Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2))),
));
gb = Eval(gb_expr);
gb << Save Script to Data Table("My nice graph");
gb << Close Window;
Wait(0);
5. Erstellen Sie Formeln basierend auf Benutzerauswahlen aus Col-Listboxen
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
nw = New Window("Selections",
clb_x = Col List Box(dt, << Set items({"height"})),
clb_y = Col List Box(dt, << Set items({"weight"}))
);
x_selection = clb_x << get items;
y_selection = clb_y << get items; // these are strings
wait(2);
nw << Close Window;
// Using Eval(EvalExpr())
Eval(EvalExpr(
dt << New Column("Multiplication_EvalExpr", Numeric, Continuous, Formula(
Expr(NameExpr(AsColumn(dt, x_selection))) * Expr(NameExpr(AsColumn(dt, y_selection)))
));
));
// Using Eval(Substitute())
Eval(Substitute(
Expr(dt << New Column("Multiplication_EvalSubstitute", Numeric, Continuous, Formula(_xcol_ * _ycol_))),
Expr(_xcol_), Name Expr(AsColumn(dt, x_selection)),
Expr(_ycol_), Name Expr(AsColumn(dt, y_selection))
));
6. Verwenden Sie Ausdrücke, um Benutzeroberflächen zu erstellen (nicht das beste Beispiel)
Problem:
Code wird klobig
Names Default To Here(1);
nw = New Window("asdas",
Button Box("Perform Action1",
Caption("Perform Action1")
),
Button Box("Perform Action2",
Caption("Perform Action2")
),
Button Box("Perform Action3",
Caption("Perform Action3")
)
);
Problem2:
Mein Code funktioniert nicht (kann passieren, weil das Fenster nicht immer alle Variablen kennt)
Names Default To Here(1);
caption_expr = Expr(
Caption("Perform Action");
);
nw = New Window("asdas",
Button Box("Perform Action1",
caption_expr
),
Button Box("Perform Action2",
caption_expr
),
Button Box("Perform Action3",
caption_expr
)
);

Lösung1:
Bewerten Sie den Ausdruck
Names Default To Here(1);
caption_expr = Expr(
Caption("Perform Action");
);
Eval(EvalExpr(
nw = New Window("asdas",
Button Box("Perform Action1",
Expr(Name Expr(caption_expr))
),
Button Box("Perform Action2",
Expr(Name Expr(caption_expr))
),
Button Box("Perform Action3",
Expr(Name Expr(caption_expr))
)
);
))
Lösung2:
In diesem Fall könnten Sie auch << Set Function(Function([})) verwenden.
Names Default To Here(1);
nw = New Window("asdas",
Button Box("Perform Action1", << Set Function(function({this},
Caption(this << get button name);
))),
Button Box("Perform Action2", << Set Function(function({this},
Caption(this << get button name);
))),
Button Box("Perform Action3", << Set Function(function({this},
Caption(this << get button name);
)))
);
Lösung3:
Kombinieren
Names Default To Here(1);
button_caption_expr = Expr(
Caption(this << get button name);
);
Eval(EvalExpr(
nw = New Window("asdas",
Button Box("Perform Action1", << Set Function(function({this},
Expr(NameExpr(button_caption_expr));
))),
Button Box("Perform Action2", << Set Function(function({this},
Expr(NameExpr(button_caption_expr));
))),
Button Box("Perform Action3", << Set Function(function({this},
Expr(NameExpr(button_caption_expr));
)))
);
));
Lösung 4:
Funktion verwenden (Lösung 3 ist möglicherweise robuster)
Names Default To Here(1);
show_btn_caption = function({btn_ref}, {Default Local},
Caption(btn_ref << get button name);
);
nw = New Window("asdas",
Button Box("Perform Action1", << Set Function(function({this},
show_btn_caption(this);
))),
Button Box("Perform Action2", << Set Function(function({this},
show_btn_caption(this);
))),
Button Box("Perform Action3", << Set Function(function({this},
show_btn_caption(this);
)))
);
Lösung5:
Verwenden Sie die Funktion, um die Schaltflächen zu erstellen
Names Default To Here(1);
create_btn = function({btn_title}, {Default Local},
btn = Button Box(btn_title, << Set Function(function({this},
Caption(btn_ref << get button name);
)));
return(btn);
);
nw = New Window("asdas",
create_btn("Perform Action1"),
create_btn("Perform Action2"),
create_btn("Perform Action3")
);