概述
當使用 JMP ®腳本語言 (JSL) 產生自訂視窗以提示使用者輸入資訊時,通常需要新增一個按鈕來恢復相同 JMP 實例中先前啟動視窗的設定。以互動方式啟動平台時可以使用類似的功能,例如透過點擊「分析」選單並選擇「分發」 。
目前,沒有內建的 JSL 方法可用於建立「Recall」按鈕,正如您在「分發」平台啟動和「表格」選單對話方塊中看到的那樣。但是,您可以創建自己的實作。
以下範例產生一個自訂窗口,使用者可以在其中將活動資料表中的列轉換為適當的角色。按一下「確定」按鈕後,使用者的設定將儲存在命名空間中定義的變數中。在隨後啟動視窗時,「呼叫」按鈕會清除所有目前設定並恢復命名空間中的值。
指示
在 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 )
)
)
)
)
);
)
);