ボタンボックススクリプトに評価された式を持たせる方法こんにちは、
個々のアウトライン ボックスをスクリプトでポイントするボタン ボックスの自動追加を作成しようとしています (例として、スクロール ウィンドウまたは閉じる) - リストにスクリプト項目の名前を挿入する For ループを使用して式を構築することはできますが、各ボタン ボックスに一意のスクリプトを持たせようとすると、代わりに式の名前 'buttonclickexpr' がスクリプトとして保持されます。
式内のスクリプトを評価して、クリック時にボタン ボックスが実行される記述コマンドとして正しく配置するにはどうすればよいですか?
//an example of how the window could appear
report_win=new window("test", content_VLB=V List Box(), Outline Box("Example: Distribution"), Outline Box("Example: Multivariate"));
//example of the variable that would store the name of scripts that created the OBs
script_new={"Distribution", "Multivariate", "Profiler"};
//the for loop to correctly setup the expression with the correct section name and add a button
For( i = 1, i <= N Items( script_new ), i++,
buttonclickexpr = Expr(
report_win << Scroll Window(
report_win[Outline Box( sectionName)]
)
);
Substitute Into( buttonclickexpr, Expr(sectionName), Char("Example: " ||script_new[i]) );
write(buttonclickexpr);
// Add a button to the list
content_VLB<
<APPEND></APPEND>
<BR />
<LINGO-LABS id="lingo-labs-914974" slang="en-US" mode="CREATE">
<LINGO-LABEL>自動化とスクリプト</LINGO-LABEL>
</LINGO-LABS>
Re: ボタンボックススクリプトに評価された式を持たせる方法Eval(Eval Expr()) を使用できます。
//an example of how the window could appear
report_win = New Window( "test",
content_VLB = V List Box(),
Scroll box (Size(20,1500)),
Outline Box( "Example: Distribution" ),
Scroll box (Size(20,1500)),
Outline Box( "Example: Multivariate" )
);
//example of the variable that would store the name of scripts that created the OBs
script_new = {"Distribution", "Multivariate", "Profiler"};
//the for loop to correctly setup the expression with the correct section name and add a button
For( i = 1, i <= N Items( script_new ), i++,
buttonclickexpr = Expr(
report_win << Scroll Window( report_win[sectionName ] );
Caption(sectionName)
);
Substitute Into( buttonclickexpr, Expr( sectionName ), Char( "Example: " || script_new[i] ) );
Write( buttonclickexpr );
// Add a button to the list
Eval (Eval Expr(content_VLB << append( Button Box( "Go to " || script_new[i], Expr(Name Expr(buttonclickexpr)))) ));
);
アウトラインボックス("タグ")では、タグはOutlineBoxのHelperKeyです。タイトルからアウトラインボックスにアクセスするには、タイトルを直接使用できます( アウトラインボックス()は使用しません)。
詳細については、「Re: JMPにおける式の処理:ヒントとトラップドア」を参照してください。
| 使用 |
|
| 名前式() |
... to retrieve the expression that is stored in the name buttonclickexpr |
| 式() |
...コードをマークする - 式の評価()がそれを見つけられるようにする |
| 式の評価() |
...式()を見つけて評価する |
| 評価() |
前の手順の後に式全体を評価します。 |
Re: ボタンボックススクリプトに評価された式を持たせる方法代替アプローチ: 代わりの()
[ buttonclickexpr を調整するために既に使用されています *)]
両方のステップを 1 つにまとめます。
For each ({title}, script_new ,
myExpr = Expr(
content_VLB << append( Button Box( "Go to " || title,current report() << Scroll Window( current report()[_sectionName_ ] )));
);
Eval(Substitute (Name Expr(myExpr), Expr( _sectionName_ ), "Example: " || title ));
);
| 使用 |
|
| 代わりの() |
... Substitute for String と似ていますが、引数は評価されることに注意してください。そのため、... を使用する必要があります。 |
| 名前式() |
... マイエクスプレッションという名前で保存されている式を取得するには - 評価せずに!!! |
| 式() |
... to protect _sectionName_ from getting evaluated |
| 評価() |
前の手順の後に式全体を評価します。 |
*) Substitute以外。Substitute Into()は最初の引数を評価しません。