다음은 여러분이 접할 수 있는 몇 가지 매우 일반적인 문제와 표현식을 사용하고 필요할 때 평가하여 문제를 해결할 수 있는 방법입니다.
1. 수식에 상수 사용
문제:
수식은 한 번만 작동하며 저장하고 다시 열면 다음과 같이 표시됩니다.

해결책:
Eval Insert, Eval Expr, Parse 및 Substitute를 사용하여 하나의 표현식을 다른 표현식에 삽입합니다. . 대부분의 경우 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. 그래픽 스크립트에서 상수 사용하기
문제:
다음과 같은 스크립트로 끝납니다.
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);
)}
)
)
);
해결책:
Eval(EvalExpr()) 사용(또는 Substitute()가 다른 좋은 옵션임)
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. 변수를 사양 한계로 설정
문제:
사양 제한이 올바르게 설정되지 않았습니다.
해결책:
JMP가 코드를 생성하도록 허용하여 시작하십시오(열 속성을 추가하고 확장 로그에서 코드를 가져오거나 열을 마우스 오른쪽 버튼으로 클릭하고 "열 속성 복사"). 당신은 이런 것을 얻습니다
Data Table("Big Class"):height << Set Property(
"Spec Limits",
{LSL(11), USL(22), Target(12), Show Limits(1)}
);
변수를 사용하도록 이 스크립트를 개선하세요.
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. 테이블에 테이블 스크립트 추가하기
문제:
다음과 같은 테이블 스크립트가 생성됩니다.

해결책:
이름 Expr()이 있는 Eval(EvalExpr()). 그래프가 전혀 생성되지 않습니다. 실행하려면 << Run Script("My nice graph")를 사용하거나 표현식을 평가하세요.
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>하지만 이와 같은 경우에는 대부분 << 데이터 테이블에 스크립트 저장을 사용하지만 이는 플랫폼을 실행하므로 닫는 것을 기억하세요.</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. 열 목록 상자의 사용자 선택을 기반으로 수식 작성
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. 표현식을 사용하여 사용자 인터페이스 구축(가장 좋은 예는 아님)
문제:
코드가 엉성해짐
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")
)
);
문제 2:
내 코드가 작동하지 않습니다(창이 모든 변수에 대해 항상 알지 못하기 때문에 발생할 수 있음).
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
)
);

솔루션1:
표현을 평가해 보세요
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))
)
);
))
해결책2:
이 경우 << Set Function(Function([})) 을 사용할 수도 있습니다.
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);
)))
);
해결책3:
결합하다
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));
)))
);
));
해결 방법 4:
기능 사용(솔루션3이 더 강력할 수 있음)
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);
)))
);
솔루션5:
함수를 사용하여 버튼 만들기
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")
);