<?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 index into a table box of check boxes in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108879#M39551</link>
    <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I have a m by n Table box of check boxes. I am wondering, how I can set some of them selected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;          LB_b = Lineup Box(N Col(1)); 
	  nR = 10;
	  nC = 10;
	  SCB1 = String Col Box( "", {} ); 
	  For( i = 1, i &amp;lt;= nR, i++,
			SCB1 &amp;lt;&amp;lt; Add Element( Char( i ) )
		 );
	  TB1 = Table Box( SCB1 ); 																																						
	  For( i = 1, i &amp;lt;= nC, i++,
			Insert Into( TB1, Check Box( Repeat( {" "}, nR ), &amp;lt;&amp;lt;Set Heading( Char( i ) ) ) )
		 );				
	  LB_b &amp;lt;&amp;lt; Append(TB1);
	  
	  T = New Window("Test",TB1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; When I look at the tree structure, I wonder why I am unable to access the elements. I tried&amp;nbsp; something like the following&amp;nbsp; with no luck. Also, the goal is not to be able to select a column of check boxes, but a single checkbox in the matrix.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;TB1["CheckBoxBox(1)"] &amp;lt;&amp;lt; select ; &lt;BR /&gt;&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Feb 2019 04:38:37 GMT</pubDate>
    <dc:creator>uday_guntupalli</dc:creator>
    <dc:date>2019-02-05T04:38:37Z</dc:date>
    <item>
      <title>How to index into a table box of check boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108879#M39551</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; I have a m by n Table box of check boxes. I am wondering, how I can set some of them selected.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;          LB_b = Lineup Box(N Col(1)); 
	  nR = 10;
	  nC = 10;
	  SCB1 = String Col Box( "", {} ); 
	  For( i = 1, i &amp;lt;= nR, i++,
			SCB1 &amp;lt;&amp;lt; Add Element( Char( i ) )
		 );
	  TB1 = Table Box( SCB1 ); 																																						
	  For( i = 1, i &amp;lt;= nC, i++,
			Insert Into( TB1, Check Box( Repeat( {" "}, nR ), &amp;lt;&amp;lt;Set Heading( Char( i ) ) ) )
		 );				
	  LB_b &amp;lt;&amp;lt; Append(TB1);
	  
	  T = New Window("Test",TB1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; When I look at the tree structure, I wonder why I am unable to access the elements. I tried&amp;nbsp; something like the following&amp;nbsp; with no luck. Also, the goal is not to be able to select a column of check boxes, but a single checkbox in the matrix.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;TB1["CheckBoxBox(1)"] &amp;lt;&amp;lt; select ; &lt;BR /&gt;&lt;/CODE&gt;&lt;CODE class=" language-jsl"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 04:38:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108879#M39551</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-02-05T04:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to index into a table box of check boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108881#M39553</link>
      <description>&lt;P&gt;You have 2 reference issues with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;TB1["CheckBoxBox(1)"] &amp;lt;&amp;lt; select ; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first is that&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;TB1["CheckBoxBox(1)"]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is looking for an Outline Box with the title "CheckBoxBox()".&amp;nbsp; That is, you have placed "CheckBoxBox()" in quotes, and there for it is not looking for a CheckBoxBox() object, it is looking for an object with the title "CheckBoxBox(1)". &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly,&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt; Select&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is not a message that CheckBoxBox() has available to it. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;TB1[CheckBoxBox(1)] &amp;lt;&amp;lt;  get selected ; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #000000; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 21px; -ms-hyphens: none; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: 0px; word-wrap: normal;"&gt;would be what you want, except for the fact that &amp;lt;&amp;lt; get selected returns the string values for each of the check boxes selected, and since all of your string values for your check boxes are set to " ", that will be all you will be returned. So what you will need to do is to loop through each of the check boxes, and find the values. Here is a simple example&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( c = 1, c &amp;lt;= 10, c++,
	For( r = 1, r &amp;lt;= 10, r++,
		If( T[CheckBoxBox( c )] &amp;lt;&amp;lt; get( r ) == 1,
			Show( c, r )
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 13:14:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108881#M39553</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-02-05T13:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to index into a table box of check boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108883#M39554</link>
      <description>&lt;P&gt;Here's a way to do what you need:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;n = 10;		// # rows
m = 10;		// # cols
a = 1::n;

// Create a list of empty text fields as checkbox labels
cb_list = {};
for (i = 1, i &amp;lt;= n, i++,
	cb_list[i] = "";
);


cbmat = j(n, m, 0);
// Create the window
nw = new window("Test",
	tb = table box(
		ncb = number col box("", a),
	),
	okb = button box("OK",
		for (i = 1, i &amp;lt;= m, i++,
			for (k = 1, k &amp;lt;= n, k++,
				cbmat[k, i] = cb[i] &amp;lt;&amp;lt; get(k);
			),
		);
		show(cbmat);
		nw &amp;lt;&amp;lt; close window;
	),
);

// Create an array of checkbox columns
cb = {};
// Add the checkboxes
for (i = 1, i &amp;lt;= m, i++,
	cb[i] = checkbox(cb_list);
	cb[i] &amp;lt;&amp;lt; set heading(char(i));
	tb &amp;lt;&amp;lt; append(cb[i]);
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="checkbox_matrix.png" style="width: 287px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15407iE3352F199BAA06F2/image-size/large?v=v2&amp;amp;px=999" role="button" title="checkbox_matrix.png" alt="checkbox_matrix.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;cbmat = 
[	1 0 0 0 0 0 0 0 0 0, 
	1 0 0 0 0 0 0 0 0 0, 
	1 0 1 0 0 0 0 0 0 0, 
	0 0 1 0 0 0 0 0 0 0, 
	0 0 1 0 1 0 0 0 0 0, 
	0 0 0 0 1 0 1 0 0 0, 
	0 0 0 0 0 0 1 0 0 0, 
	0 0 0 0 0 0 1 0 0 0, 
	0 0 0 0 0 0 0 0 0 0, 
	0 0 0 0 0 0 0 0 0 0];&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 13:35:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108883#M39554</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2019-02-05T13:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to index into a table box of check boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108896#M39556</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thank you for your responses. However, if I may, I think the primary part of my question that is, how do I set them to selected(My bad - I should have asked checked) doesn't seem to have been addressed. Could either of you guide me as to how I can check any of the checkboxes ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I think&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4550"&gt;@pmroz&lt;/a&gt;&amp;nbsp; 's response provides a way to index to the checkbox, but I think it references them by column, not so much by each individual check box. I will try and illustrate in a little more detail what I seek:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The snippet I posted gives me a matrix of selectable checkboxes like so:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 457px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15408i6C571F9BCB542615/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Now, should a user make his selection, I am able to unload the selection using the following:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NW = New Window("Test",
					VLB0 = V List Box(Align(center),
									  LB_b
									 )
			   ); 
VLB0 &amp;lt;&amp;lt; Append(
				H List Box(
								BB_TargetMatrix = Button Box( "OK", 
																																															
																ResMat = {}; 
																// loop through each row
																For( i = 1, i &amp;lt;= nR, i++, 
																		ResMat[i] = {};
																		// loop through each column getting values
																		For( r = 1, r &amp;lt;= nC, r++,
																				ResMat[i][r] = TB1[CheckBoxBox( r )] &amp;lt;&amp;lt; get( i )
																		   );	
																   );	
																ResMat = Matrix( ResMat );
																																								
															)// end of button box 
							 )// end of H List Box 
			  );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 318px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/15409iFD01D43F7113D24F/image-dimensions/318x469?v=v2" width="318" height="469" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;However, I would like to know how I can the table box with some of the checkboxes pre-checked. I have a matrix the same size as the table box, which I would like to use to set the checkboxes checked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 14:28:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108896#M39556</guid>
      <dc:creator>uday_guntupalli</dc:creator>
      <dc:date>2019-02-05T14:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to index into a table box of check boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108906#M39558</link>
      <description>&lt;P&gt;This code will set the checkboxes from a saved matrix of 1s and 0s.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Set some random values in this matrix
saved_cbmat = 
[	1 0 0 1 0 0 0 0 0 0, 
	0 0 0 0 0 0 0 0 0 0, 
	0 1 0 0 0 0 0 0 0 0, 
	0 1 0 0 0 0 1 0 0 0, 
	0 1 0 1 0 0 1 0 1 0, 
	0 0 0 0 0 0 0 0 0 1, 
	0 0 0 0 0 0 0 0 1 1, 
	0 0 0 0 0 0 0 0 1 0, 
	0 0 0 0 0 0 0 0 1 0, 
	0 0 0 0 0 0 0 0 0 0];

n = 10;		// # rows
m = 10;		// # cols
a = 1::n;

// Create a list of empty text fields as checkbox labels
cb_list = {};
for (i = 1, i &amp;lt;= n, i++,
	cb_list[i] = "";
);


cbmat = j(n, m, 0);
// Create the window
nw = new window("Test",
	tb = table box(
		ncb = number col box("", a),
	),
	okb = button box("OK",
		for (i = 1, i &amp;lt;= m, i++,
			for (k = 1, k &amp;lt;= n, k++,
				cbmat[k, i] = cb[i] &amp;lt;&amp;lt; get(k);
			),
		);
		show(cbmat);
		nw &amp;lt;&amp;lt; close window;
	),
);

// Create an array of checkbox columns
cb = {};
// Add the checkboxes
for (i = 1, i &amp;lt;= m, i++,
	cb[i] = checkbox(cb_list);
	cb[i] &amp;lt;&amp;lt; set heading(char(i));
	tb &amp;lt;&amp;lt; append(cb[i]);
);

// Preload the checkboxes from the saved matrix
for (i = 1, i &amp;lt;= m, i++,
	for (k = 1, k &amp;lt;= n, k++,
		on_off = saved_cbmat[k, i];
		cb[i] &amp;lt;&amp;lt; set(k, on_off);
	),
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 14:36:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-index-into-a-table-box-of-check-boxes/m-p/108906#M39558</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2019-02-05T14:36:31Z</dc:date>
    </item>
  </channel>
</rss>

