<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to parse commas within a List Box in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870668#M103420</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am on JMP 18.1.2 and am attempting to create a matrix of check boxes. The final step which I cannot figure out, is how to dynamically create the H List Box based on number of rows.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;This is my current code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test = {"a","b","c","d","e"};
testFin = {};
rows = 2;
remain = Modulo(N Items(test), rows);
loops = 2 + (remain &amp;gt; 0);
//create a list that groups the original list in groups of 2 (rows)
for(i=1, i&amp;lt;= loops, i++,
	test2 = {};
	if(i != loops,
		for(j = 1, j&amp;lt;= rows, j++,
			test2[j] = test[1];
			test = remove(test,1);
		);
		,
		for(j = 1, j&amp;lt;= 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&amp;lt;= 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", &amp;lt;&amp;lt;Modal,
	H List Box(
		parse(ttp);
	),
	H List Box(
		Button Box("OK",
			//testing
			cbtemp = cb[1] &amp;lt;&amp;lt; Get Selected();
		),
		Button Box("Cancel", cancel_check = 1);
	);
);
if(cancel_check == 1,
	Stop()
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error I get when trying to run it is:&lt;/P&gt;
&lt;PRE&gt;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]);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The desired output (if I just replaced the parse with what ttp is and ran it) is attached and also below.&lt;BR /&gt;Thank you!&lt;/P&gt;
&lt;P&gt;_________________&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired Output" style="width: 155px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75280iED2528631ABBDFE7/image-size/small?v=v2&amp;amp;px=200" role="button" title="Annotation 2025-04-28 172813.png" alt="Desired Output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Desired Output&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Apr 2025 21:32:03 GMT</pubDate>
    <dc:creator>CohortMapping26</dc:creator>
    <dc:date>2025-04-28T21:32:03Z</dc:date>
    <item>
      <title>How to parse commas within a List Box</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870668#M103420</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am on JMP 18.1.2 and am attempting to create a matrix of check boxes. The final step which I cannot figure out, is how to dynamically create the H List Box based on number of rows.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;This is my current code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test = {"a","b","c","d","e"};
testFin = {};
rows = 2;
remain = Modulo(N Items(test), rows);
loops = 2 + (remain &amp;gt; 0);
//create a list that groups the original list in groups of 2 (rows)
for(i=1, i&amp;lt;= loops, i++,
	test2 = {};
	if(i != loops,
		for(j = 1, j&amp;lt;= rows, j++,
			test2[j] = test[1];
			test = remove(test,1);
		);
		,
		for(j = 1, j&amp;lt;= 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&amp;lt;= 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", &amp;lt;&amp;lt;Modal,
	H List Box(
		parse(ttp);
	),
	H List Box(
		Button Box("OK",
			//testing
			cbtemp = cb[1] &amp;lt;&amp;lt; Get Selected();
		),
		Button Box("Cancel", cancel_check = 1);
	);
);
if(cancel_check == 1,
	Stop()
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error I get when trying to run it is:&lt;/P&gt;
&lt;PRE&gt;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]);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The desired output (if I just replaced the parse with what ttp is and ran it) is attached and also below.&lt;BR /&gt;Thank you!&lt;/P&gt;
&lt;P&gt;_________________&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Desired Output" style="width: 155px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75280iED2528631ABBDFE7/image-size/small?v=v2&amp;amp;px=200" role="button" title="Annotation 2025-04-28 172813.png" alt="Desired Output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Desired Output&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Apr 2025 21:32:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870668#M103420</guid>
      <dc:creator>CohortMapping26</dc:creator>
      <dc:date>2025-04-28T21:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse commas within a List Box</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870695#M103423</link>
      <description>&lt;P&gt;I changed up your script a bit.&amp;nbsp; I continued using your methodology of building a string that contains the elements required to display the Check Boxes.&lt;/P&gt;
&lt;P&gt;I also used&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Eval( Eval Expr())&lt;/P&gt;
&lt;P&gt;To force the evaluation of the string before executing it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1745890770707.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/75284i53ED37C5E8394391/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1745890770707.png" alt="txnelson_0-1745890770707.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
test = {"a", "b", "c", "d", "e"};
testFin = {};
rows = 2;
remain = Modulo( N Items( test ), rows );
loops = 2 + (remain &amp;gt; 0);
//create a list that groups the original list in groups of 2 (rows)
For( i = 1, i &amp;lt;= loops, i++,
	test2 = {};
	If( i != loops,
		For( j = 1, j &amp;lt;= rows, j++,
			test2[j] = test[1];
			test = Remove( test, 1 );
		)
	,
		For( j = 1, j &amp;lt;= 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 &amp;lt;= 2, k++,
	For( i = 1, i &amp;lt;= 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",
			&amp;lt;&amp;lt;Modal,
			Expr( Parse( ttp ) ),
			H List Box(
				Button Box( "OK", 
			//testing
					cbtemp = cb[1] &amp;lt;&amp;lt; Get Selected()
				),
				Button Box( "Cancel", cancel_check = 1 )
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Apr 2025 01:40:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870695#M103423</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-04-29T01:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse commas within a List Box</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870700#M103425</link>
      <description>&lt;P&gt;I would avoid Parse() as it can be a nightmare to debug and it will teach you horrible ways of writing JSL script. I would attempt to do something like this or something similar which would avoid using Parse()&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

test = {"a", "b", "c", "d", "e"};
testFin = {};
rows = 2;
remain = Modulo(N Items(test), rows);
loops = 2 + (remain &amp;gt; 0);

//create a list that groups the original list in groups of 2 (rows)
For(i = 1, i &amp;lt;= loops, i++,
	test2 = {};
	If(i != loops,
		For(j = 1, j &amp;lt;= rows, j++,
			test2[j] = test[1];
			test = Remove(test, 1);
		)
	,
		For(j = 1, j &amp;lt;= 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 &amp;lt;= N Items(testFin), i++,
	hlb &amp;lt;&amp;lt; Append(cbs[i] = Check Box(testFin[i]));
);

testw = New Window("raaa",
	&amp;lt;&amp;lt;Modal,
	hlb,
	H List Box(
		Button Box("OK", 
			//testing
			cbtemp = cb[1] &amp;lt;&amp;lt; Get Selected()
		),
		Button Box("Cancel", cancel_check = 1)
	)
);

If(cancel_check == 1, Stop());&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Apr 2025 04:28:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-parse-commas-within-a-List-Box/m-p/870700#M103425</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-04-29T04:28:52Z</dc:date>
    </item>
  </channel>
</rss>

