概要
JMP ®スクリプト言語 (JSL) を使用して、ユーザーに情報の入力を促すカスタム ウィンドウを生成する場合、同じ JMP インスタンス内でウィンドウを前回起動したときの設定を復元するボタンを追加することが望ましいことがよくあります。同様の機能は、分析メニューをクリックして分布を選択するなど、プラットフォームを対話的に起動するときにも利用できます。
現在、Distribution プラットフォームの起動およびテーブル メニュー ダイアログに表示される [Recall] ボタンを作成するための組み込み JSL メソッドはありません。ただし、独自の実装を作成することはできます。
次の例では、ユーザーがアクティブなデータ テーブルの列を適切なロールにキャストできるカスタム ウィンドウを生成します。[OK] ボタンをクリックすると、ユーザーの設定が名前付き名前空間で定義された変数に保存されます。その後ウィンドウを起動すると、[呼び出し] ボタンによって現在の設定がすべてクリアされ、名前空間の値が復元されます。
説明書
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 )
)
)
)
)
);
)
);