概述
使用 JMP ®脚本语言 (JSL) 生成自定义窗口以提示用户输入信息时,通常需要添加一个按钮,用于在同一 JMP 实例中恢复上次启动窗口时的设置。以交互方式启动平台时也可以使用类似的功能,例如单击“分析”菜单并选择“分布” 。
目前,没有内置 JSL 方法来创建“调用”按钮,如您在“分发”平台启动和“表格”菜单对话框中所见。但是,您可以创建自己的实现。
以下示例生成一个自定义窗口,用户可以在其中将活动数据表中的列转换为适当的角色。单击“确定”按钮后,用户的设置将存储在命名命名空间中定义的变量中。在随后启动窗口时,“调用”按钮将清除所有当前设置并恢复命名空间中的值。
指示
在 JMP 会话中,单击文件菜单并选择新建 ► 脚本。复制以下脚本并将其粘贴到脚本窗口中。要运行示例脚本,请单击编辑菜单并选择运行脚本。
Names Default to Here(1);
/* Assign dt to reference a table. Open a sample table for demonstration purposes */
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
/* Use a named namespace to hold the recall values */
if(!Namespace Exists("Custom Dialog"), // define namespace if it does not exist
dialogRecallNS = New Namespace("Custom Dialog",
{
ycolRecall = {},
orderRecall = {},
byRecall = {}
});
, // else get a reference to the existing namespace
dialogRecallNS = NameSpace("Custom Dialog");
);
nc = N Col( dt );
lbWidth = 130;
/* Expression to clear all current settings */
clearRoles = Expr(
colListY << RemoveAll;
colListX << RemoveAll;
colListB << RemoveAll;
);
/* Expression to store the current settings in global variables */
recallRoles = Expr(
dialogRecallNS:ycolRecall = colListY << GetItems;
dialogRecallNS:orderRecall = colListX << GetItems;
dialogRecallNS:byRecall = colListB << GetItems;
);
/* Custom Launch Window */
customDlg = New Window( "Example of a Custom Dialog",
Border Box( Left( 3 ), top( 2 ),
V List Box(
Text Box( "Example dialog to demonstrate a Recall button" ),
H List Box(
V List Box(
Panel Box( "Select Columns",
colListData = Col List Box( All, width( lbWidth ), nLines( Min( nc, 10 ) ) )
)
),
Panel Box( "Cast Selected Columns into Roles",
Lineup Box( N Col( 2 ), Spacing( 3 ),
Button Box( "Y, Response", colListY << Append( colListData << GetSelected ) ),
colListY = Col List Box( width( lbWidth ), nLines( 5 ), numeric ),
Button Box( "X, Factor", colListX << Append( colListData << GetSelected ) ),
colListX = Col List Box( width( lbWidth ), nLines( 1 ), numeric ),
Button Box( "By", colListB << Append( colListData << GetSelected ) ),
colListB = Col List Box( width( lbWidth ), nLines( 1 ) )
)
),
Panel Box( "Action",
Lineup Box( N Col( 1 ),
Button Box( "OK",
recallRoles;
customDlg << CloseWindow;
),
Button Box( "Cancel", customDlg << CloseWindow ),
Button Box( "Reset", clearRoles ),
Text Box( " " ),
Button Box( "Remove",
colListY << RemoveSelected;
colListX << RemoveSelected;
colListB << RemoveSelected;
),
Button Box( "Recall",
clearRoles;
/* Restore any previous settings from the namespace variables */
Try(
colListY << Append( dialogRecallNS:ycolRecall );
colListX << Append( dialogRecallNS:orderRecall );
colListB << Append( dialogRecallNS:byRecall );
);
)
)
)
)
)
)
);
其他文档
有关 JMP 脚本语言的更多信息,请参阅JMP 脚本指南您可以在 JMP 中点击帮助菜单并选择JMP 帮助。从在线目录中选择脚本指南.
[先前的 JMP 说明 46984]
我查看了脚本,它看起来像是我需要的,但是,我不知道如何添加生成的情节脚本来利用它。我的原始脚本看起来像这样,但缺少一个调用按钮。不确定将脚本附加到哪里?另外,我需要将这个脚本设为模态吗?
斯兰
扳手头
dt = Current Data Table();
cd = Column Dialog(
exy = ColList( "Y", Min Col( 1 ) ),
exx = ColList( "X", Min Col( 1 ) )
);
Eval( cd[1] );
Eval( cd[2] );
yyy = Expr( y() );
xxx = Expr( x() );
xval = exx[1];
For( i = 1, i <= N Items( exy ), i++,
Insert Into( yyy, exy[i] )
);
For( i = 1, i <= N Items( exx ), i++,
Insert Into( xxx, exx[i] )
);
nw = New Window( "Annotated Multiple Plots",
For( i = 1, i <= N Items( exy ), i++,
Notes = exy[i] << Get Property( "Notes" );
Try(
Bivariate(
Y( exy[i] ),
X( exx[1] ),
SendToReport(
Dispatch(
{},
"",
AxisBox( 2 ),
Add Text Annotation(
Text( "Category: " || Notes ),
Fixed Size( 0 ),
Text Box( {-80, 25, 0, 50} ),
Filled( 0 )
)
)
)
)
);
)
);