如何在不同的 jsl 脚本上使用另一个表达式中的组合框获取选定值?大家好,
我有 2 个脚本。 ScriptA 有一个表达式来构建具有动态限制的双变量图表。 ScriptB 基本上是一个前端应用程序代码,它要求用户选择 x 轴和 y 轴列名称。 我想将来自 ScriptB 的用户的选定输入(即从组合框中选择)用于我的 ScriptA 表达式代码,以获取双变量图表作为选定列的输出。
我的目标是在运行脚本 B 时获取带有所选参数的滑块的图表!!
</CODE></PRE>
<PRE><CODE class=" language-jsl">////////////////////////////////////SCRIPT A//////////////////////////////////////
DT = open("data.jmp", invisible);
//Getting the inputs
x = inputParameter << get Selected;
y = response << get Selected;
z = blocking << get Selected;
//Making graphs
myFinalDisplay = expr(
myGbDispObj = dt << Bivariate(
Size( 550, 400 ),
Y( Eval(y) ),
X( Eval(x) ),
Automatic Recalc( 1 ),
Histogram Borders( 1 ),
Summary Statistics( 1 ),
Fit Spline( 2, {Line Color( {212, 73, 88} )} ),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Row Legend(
Eval(z),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 1 ),
Marker Theme( "Solid" ),
Continuous Scale( 1 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {}, "Summary Statistics", OutlineBox, {Close( 1 )} )
)
);
myLimitCol = column(DT, Eval(x));
myLimitMin = colMinimum(myLimitCol); show(myLimitMin);
myLimitMax = colMaximum(myLimitCol); show(myLimitMax);
myTbLo = textBox(Char(round(myLimitMin, 2)) || " (OOC = " || char(0.00, 10, 2) || "%)");
myTbHi = textBox(Char(round(myLimitMax, 2)) || " (OOC = " || char(0.00, 10, 2) || "%)");
mySbDispObj = rangeSliderBox(
myLimitMin,
myLimitMax,
32,
36,
//script
mySelectedLower = mySbDispObj << getLower;
mySelectedUpper = mySbDispObj << getUpper;
myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedLower, "Dashed", "blue", "LCL", 4 )} );
myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedUpper, "Dashed", "blue", "UCL", 4 )} );
rUpper = dt << Get Rows Where( myLimitCol[] > mySelectedUpper );
OOC_valUpper = (N Items(rUpper) / N rows(dt))*100;
myTbHi << setText(Char(round(mySelectedUpper, 1)) || " (OOC = " || char(OOC_valUpper, 10, 2) || "%)");
rLower = dt << Get Rows Where( myLimitCol[] < mySelectedLower );
OOC_valLower = (N Items(rLower) / N rows(dt))*100;
myTbLo << setText(Char(round(mySelectedLower, 1)) || " (OOC = " || char(OOC_valLower, 10, 2) || "%)");
);
mySbDispObj << Set Width( 275 );
myLayout = vListBox(
myGbDispObj,
hListBox(myTbLo, spacerBox(size(50,0)), myTbHi),
mySbDispObj
);
);
//PLATFORM = newWindow("TEST", vListBox(myFinalDisplay));
////////////////////////////////////SCRIPT A ENDS///////////////////////////////////////////////////////////////////////SCRIPT B///////////////////////////////////////////////////
include("ScriptA");
myStaticLibContainer = vListBox(); //Making a static container
//////Calling the expression "myFinalDisplay" from ScriptA and adding it to the static container//////
sliderGraph = buttonBox("Get Slider Graph", myStaticLibContainer << append(vListBox(myFinalDisplay)));
///Creating user input boxes///
inputParameter = comboBox("Parameter");
response = comboBox("Response");
blocking = comboBox("FAB");
myMainToolPanelBox = panelBox("myMainToolPanelBox",
vListBox(
spacerBox(size(1000,0)),
V List Box(Text Box("Predictor"), inputParameter),
V List Box(Text Box("Response"), response),
V List Box(Text Box("Block By"), blocking)),
H List Box(sliderGraph),
scrollBox(size(1000,550), myStaticLibContainer),
);
myPlatform = newWindow("Loss Curves", myMainToolPanelBox);
/////////////////////////////////SCRIPT B ENDS///////////////////////////////////////////////////
/////////////////////////////////////脚本A结束////// ////////////////////////////////
我还附上了数据表和脚本!!
先感谢您。
@txnelson
pmroz
数据表图形回复:如何在不同的 jsl 脚本的另一个表达式中使用从组合框中获取选定值?谢谢。 这奏效了。 变量越来越重叠。
回复:如何在不同的 jsl 脚本的另一个表达式中使用从组合框中获取选定值?我对您的脚本 A 进行了一些修改。基本上,这些更改是为了确保被调用的变量在调用它们之前已经定义。我添加了 Clear Symbols();这有助于确保变量不会徘徊。
Clear Symbols();
DT = open("data.jmp", invisible);
//Making graphs
myFinalDisplay = Expr(
//Getting the inputs
x = inputParameter << get Selected;
y = response << get Selected;
z = blocking << get Selected;
myGbDispObj = dt << Bivariate(
Size( 550, 400 ),
Y( Eval( y ) ),
X( Eval( x ) ),
Automatic Recalc( 1 ),
Histogram Borders( 1 ),
Summary Statistics( 1 ),
Fit Spline( 2, {Line Color( {212, 73, 88} )} ),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,
{Row Legend(
Eval( z ),
Color( 1 ),
Color Theme( "JMP Default" ),
Marker( 1 ),
Marker Theme( "Solid" ),
Continuous Scale( 1 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
),
Dispatch( {}, "Summary Statistics", OutlineBox, {Close( 1 )} )
)
);
myLimitCol = Column( DT, Eval( x ) );
myLimitMin = Col Minimum( myLimitCol );
Show( myLimitMin );
myLimitMax = Col Maximum( myLimitCol );
Show( myLimitMax );
myTbLo = Text Box( Char( Round( myLimitMin, 2 ) ) || " (OOC = " || Char( 0.00, 10, 2 ) || "%)" );
myTbHi = Text Box( Char( Round( myLimitMax, 2 ) ) || " (OOC = " || Char( 0.00, 10, 2 ) || "%)" );
mySbDispObj = Range Slider Box(
myLimitMin,
myLimitMax,
mySelectedLower,
mySelectedUpper,
//script
//mySelectedLower = mySbDispObj << getLower;
//mySelectedUpper = mySbDispObj << getUpper;
myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedLower, "Dashed", "blue", "LCL", 4 )} );
myGbDispObj << Dispatch( {}, "1", ScaleBox, {Add Ref Line( mySelectedUpper, "Dashed", "blue", "UCL", 4 )} );
rUpper = dt << Get Rows Where( myLimitCol[] > mySelectedUpper );
OOC_valUpper = (N Items( rUpper ) / N Rows( dt )) * 100;
myTbHi << setText( Char( Round( mySelectedUpper, 1 ) ) || " (OOC = " || Char( OOC_valUpper, 10, 2 ) || "%)" );
rLower = dt << Get Rows Where( myLimitCol[] < mySelectedLower );
OOC_valLower = (N Items( rLower ) / N Rows( dt )) * 100;
myTbLo << setText( Char( Round( mySelectedLower, 1 ) ) || " (OOC = " || Char( OOC_valLower, 10, 2 ) || "%)" );
);
mySbDispObj << Set Width( 275 );
myLayout = V List Box( myGbDispObj, H List Box( myTbLo, Spacer Box( size( 50, 0 ) ), myTbHi ), mySbDispObj );
);
//PLATFORM = newWindow("TEST", vListBox(myFinalDisplay));
脚本 B 的唯一更改是向“响应”变量添加范围界定说明。您在脚本中使用它,它也是一个列名。JMP 越来越困惑了。因此,通过在其前面添加“::”,它会强制 JMP 查找内存变量,而不是用于其用途的列
myStaticLibContainer = vListBox(); //Making a static container
//////Calling the expression "myFinalDisplay" from ScriptA and adding it to the static container//////
sliderGraph = buttonBox("Get Slider Graph", myStaticLibContainer << append(vListBox(myFinalDisplay)));
///Creating user input boxes///
inputParameter = comboBox("Parameter");
::response = comboBox("Response");
blocking = comboBox("FAB");
myMainToolPanelBox = panelBox("myMainToolPanelBox",
vListBox(
spacerBox(size(1000,0)),
V List Box(Text Box("Predictor"), inputParameter),
V List Box(Text Box("Response"), response),
V List Box(Text Box("Block By"), blocking)),
H List Box(sliderGraph),
scrollBox(size(1000,550), myStaticLibContainer),
);
myPlatform = newWindow("Loss Curves", myMainToolPanelBox);