목록 상자 내에서 쉼표를 구문 분석하는 방법안녕하세요,
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]);
원하는 출력(parse를 ttp로 바꿔서 실행한 경우)은 아래에 첨부되어 있습니다.
감사합니다!
_________________
Desired OutputDesired OutputDesired Output원하는 출력
<LINGO-LABS id="lingo-labs-870668" slang="en-US" mode="UPDATE"><LINGO-LABEL>자동화 및 스크립팅</LINGO-LABEL></LINGO-LABS>Re: 목록 상자 내에서 쉼표를 구문 분석하는 방법스크립트를 조금 수정했습니다. 체크박스를 표시하는 데 필요한 요소를 포함하는 문자열을 만드는 방법을 계속 사용했습니다.
나도 사용했어요
Eval(Eval Expr())
문자열을 실행하기 전에 강제로 문자열을 평가합니다.

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>