リストボックス内のカンマを解析する方法こんにちは、
JMP 18.1.2を使用して、チェックボックスのマトリックスを作成しようとしています。最後のステップで、行数に基づいてHリストボックスを動的に作成する方法がわかりません。
これが私の現在のコードです:
test = {"a","b","c","d","e"};
testFin = {};
rows = 2;
remain = Modulo(N Items(test), rows);
loops = 2 + (remain > 0);
//create a list that groups the original list in groups of 2 (rows)
for(i=1, i<= loops, i++,
test2 = {};
if(i != loops,
for(j = 1, j<= rows, j++,
test2[j] = test[1];
test = remove(test,1);
);
,
for(j = 1, j<= remain, j++,
test2[j] = test[1];
test = remove(test,1);
);
);
testFin[i] = test2;
);
//testFin = {{"a", "b"}, {"c", "d"}, {"e"}}
cb = {};
cancel_check = 0;
ttp = "";
for(i = 1, i<= N Items(testFin), i++,
if(i != N Items(testFin),
ttp ||= "cb["||Char(i)||"] = Check Box(testFin["||Char(i)||"]), \!n"
,
ttp ||= "cb["||Char(i)||"] = Check Box(testFin["||Char(i)||"]);"
);
);
/*ttp = "cb[1] = Check Box(testFin[1]),
cb[2] = Check Box(testFin[2]),
cb[3] = Check Box(testFin[3]);"*/
testw = new window("raaa", <<MODAL></MODAL>
<P>実行しようとすると次のエラーが発生します:</P>
Unexpected ",". Perhaps there is a missing ";" or ",".
Line 1 Column 30: cb[1] = Check Box(testFin[1])►,
The remaining text that was ignored was
,cb[2]=Check Box(testFin[2]),cb[3]=Check Box(testFin[3]);
望ましい出力 (解析を ttp の内容に置き換えて実行した場合) は添付されており、下記にも示します。
ありがとう!
_________________
Desired OutputDesired OutputDesired Output望ましい出力
<LINGO-LABS id="lingo-labs-870668" slang="en-US" mode="UPDATE"><LINGO-LABEL>自動化とスクリプト</LINGO-LABEL></LINGO-LABS>Re: リストボックス内のカンマを解析する方法スクリプトを少し変更しました。チェックボックスを表示するために必要な要素を含む文字列を構築するという手法はそのまま使いました。
私も使った
評価(評価式())
文字列を実行する前に強制的に評価します。

Names Default To Here( 1 );
test = {"a", "b", "c", "d", "e"};
testFin = {};
rows = 2;
remain = Modulo( N Items( test ), rows );
loops = 2 + (remain > 0);
//create a list that groups the original list in groups of 2 (rows)
For( i = 1, i <= loops, i++,
test2 = {};
If( i != loops,
For( j = 1, j <= rows, j++,
test2[j] = test[1];
test = Remove( test, 1 );
)
,
For( j = 1, j <= remain, j++,
test2[j] = test[1];
test = Remove( test, 1 );
)
);
testFin[i] = test2;
);
cb = {};
cancel_check = 0;
ttp = "lineupBox(ncol(" || Char( N Items( testFin ) ) || "),";
For( k = 1, k <= 2, k++,
For( i = 1, i <= N Items( testFin ), i++,
Try( ttp ||= "cb[" || Char( (k - 1) * N Items( testfin ) + i ) || "] = Check Box(\!"" || testFin[i][k] || "\!")," )
)
);
ttp = Substr( ttp, 1, Length( ttp ) - 1 ) || ")";
Eval(
Eval Expr(
testw = New Window( "raaa",
<<MODAL></MODAL>Re: リストボックス内のカンマを解析する方法Parse() はデバッグが大変になる可能性があり、JSL スクリプトのひどい書き方を教えてしまうので、避けた方が良いでしょう。Parse() を使わないようにするには、次のような方法を試してください。
Names Default To Here(1);
test = {"a", "b", "c", "d", "e"};
testFin = {};
rows = 2;
remain = Modulo(N Items(test), rows);
loops = 2 + (remain > 0);
//create a list that groups the original list in groups of 2 (rows)
For(i = 1, i <= loops, i++,
test2 = {};
If(i != loops,
For(j = 1, j <= rows, j++,
test2[j] = test[1];
test = Remove(test, 1);
)
,
For(j = 1, j <= remain, j++,
test2[j] = test[1];
test = Remove(test, 1);
)
);
testFin[i] = test2;
);
cancel_check = 0;
cbs = {};
hlb = H List Box();
For(i = 1, i <= N Items(testFin), i++,
hlb << Append(cbs[i] = Check Box(testFin[i]));
);
testw = New Window("raaa",
<<MODAL></MODAL>