<?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 Re: Create different number of text boxes based on variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721522#M90356</link>
    <description>&lt;P&gt;Store references to list, build the "collector" for text boxes outside new window and I would also move script for Slider Box outside the slider box into separate function/expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you need?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

colnames = {"name", "height", "weight"}; //it's a list of column names from previous code, number of items is not fixed

min = 0;
max = 10;
Value = 0;

lub =  Lineup Box(N Col(1));
tbs = {};
For Each({colname}, colnames,
	text_to_add = Eval Insert("^colname^: ^dt[1, colname]^");
	lub &amp;lt;&amp;lt; Append(tb = Text Box(text_to_add));
	Insert into(tbs, tb);
);

If(N Items(tbs) != N Items(colnames),
	Throw("!Fatal error");
);

update_tbs = Expr(
	For Each({colname, idx}, colnames,
		text_to_set = Eval Insert("^colname^: ^dt[1, colname]^");
		tbs[idx] &amp;lt;&amp;lt; Set Text(text_to_set);
	);
);

nw = New Window( "parameter setting",
	 Panel Box( "parameter setting",
		lub,
		Valuetb = Text Box( "Value: " || Char( Value )),
		sb = Slider Box(
			min, max, Value,
			Valuetb &amp;lt;&amp;lt; set text( "Value: " || Char( Value ));
			:age &amp;lt;&amp;lt; set each value(Value);
			update_tbs;
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Feb 2024 09:19:35 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-02-02T09:19:35Z</dc:date>
    <item>
      <title>Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721481#M90352</link>
      <description>&lt;P&gt;Dear JMPer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I try to create several text boxes in a new window,&amp;nbsp; the number of text boxes is a variable&lt;/P&gt;&lt;P&gt;Then I have a slider box , and I need to set text for those tex boxes I just created as I move the bar&lt;/P&gt;&lt;P&gt;I guess a for loop should be the solution, but I just cannot get it done&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;colname = {"Name", "Height", "Weight"}; //it's a list of column names from previous code, number of items is not fixed
min = 0;
max = 10;
Value = 0;

eval(evalexpr(
	nw = New Window( "parameter setting",
		 Panel Box( "parameter setting",
			tb1 = text box(char(colname[1]) || ": " || char(:expr(nameexpr(ascolumn(colname[1])))[1])),
			tb2 = text box(char(colname[2]) || ": " || char(:expr(nameexpr(ascolumn(colname[2])))[1])),
			tb3 = text box(char(colname[3]) || ": " || char(:expr(nameexpr(ascolumn(colname[3])))[1])),
			//.
			//.
			//.
			//.
			//.
			//.etc
			//lines for tb should determined by N itmes(colname)
			Valuetb = Text Box( "Value: " || Char( Value )),
			sb = Slider Box( 
				min, max, Value, 
				Valuetb &amp;lt;&amp;lt; set text( "Value: " || Char( Value ));
				:Parameter A &amp;lt;&amp;lt; set each value(Value);
				tb1 &amp;lt;&amp;lt; set text(char(colname[1]) || ": " || char(:expr(nameexpr(ascolumn(colname[1])))[1]));
				tb2 &amp;lt;&amp;lt; set text(char(colname[2]) || ": " || char(:expr(nameexpr(ascolumn(colname[2])))[1]));
				tb3 &amp;lt;&amp;lt; set text(char(colname[3]) || ": " || char(:expr(nameexpr(ascolumn(colname[3])))[1]))			
			) // when I move the slider box, values of all columns in colname will be changed, so I do set text for all columns in colname 
		)	
	)		
))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 07:10:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721481#M90352</guid>
      <dc:creator>BayesRabbit7133</dc:creator>
      <dc:date>2024-02-02T07:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721491#M90353</link>
      <description>&lt;P&gt;I am not sure this is what you want.&amp;nbsp; My modifications to your script changes the values to the text boxes in the display window, as you move the slider&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);
dt = open("$SAMPLE_DATA/big class.jmp");
colname = {"Name", "Height", "Weight"}; //it's a list of column names from previous code, number of items is not fixed
min = 1;
max = 10;
Value = 1;

Eval(
	Eval Expr(
		nw = New Window( "parameter setting",
			Panel Box( "parameter setting",
				tb1 = Text Box(
					Char( colname[1] ) || ": " || Char( :expr( Name Expr( As Column( colname[1] ) ) )[1] )
				),
				tb2 = Text Box(
					Char( colname[2] ) || ": " || Char( :expr( Name Expr( As Column( colname[2] ) ) )[1] )
				),
				tb3 = Text Box(
					Char( colname[3] ) || ": " || Char( :expr( Name Expr( As Column( colname[3] ) ) )[1] )
				), 
			//.
				//.
				//.
				//.
				//.
				//.etc
				//lines for tb should determined by N itmes(colname)
				Valuetb = Text Box( "Value: " || Char( Value ) ),
				sb = Slider Box(
					min,
					max,
					Value,
					Valuetb &amp;lt;&amp;lt; set text( "Value: " || Char( Value ) );
					//:Parameter A &amp;lt;&amp;lt; set each value( Value );
					tb1 &amp;lt;&amp;lt; set text(
						Char( colname[1] ) || ": " ||char(column( colname[1] )[value] ));
					tb2 &amp;lt;&amp;lt; set text(
						Char( colname[2] ) || ": " ||char(column( colname[2] )[value] ));
					tb3 &amp;lt;&amp;lt; set text(
						Char( colname[3] ) || ": " ||char(column( colname[3] )[value] ));
				) // when I move the slider box, values of all columns in colname will be changed, so I do set text for all columns in colname 
			)
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2024 07:36:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721491#M90353</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-02-02T07:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721492#M90354</link>
      <description>&lt;P&gt;Thank you Jim, but this is not what I need, no need to replace (colname[1]) [1] to value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is that when the colname list has more items in it, for example: 5, the script can do :&lt;/P&gt;&lt;P&gt;tb1 =&amp;nbsp;&lt;/P&gt;&lt;P&gt;tb2 =&amp;nbsp;&lt;/P&gt;&lt;P&gt;tb3 =&lt;/P&gt;&lt;P&gt;tb4 =&amp;nbsp;&lt;/P&gt;&lt;P&gt;tb5 =&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when it has 10 items, then do tb1 ~ tb10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 07:43:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721492#M90354</guid>
      <dc:creator>BayesRabbit7133</dc:creator>
      <dc:date>2024-02-02T07:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721522#M90356</link>
      <description>&lt;P&gt;Store references to list, build the "collector" for text boxes outside new window and I would also move script for Slider Box outside the slider box into separate function/expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this what you need?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

colnames = {"name", "height", "weight"}; //it's a list of column names from previous code, number of items is not fixed

min = 0;
max = 10;
Value = 0;

lub =  Lineup Box(N Col(1));
tbs = {};
For Each({colname}, colnames,
	text_to_add = Eval Insert("^colname^: ^dt[1, colname]^");
	lub &amp;lt;&amp;lt; Append(tb = Text Box(text_to_add));
	Insert into(tbs, tb);
);

If(N Items(tbs) != N Items(colnames),
	Throw("!Fatal error");
);

update_tbs = Expr(
	For Each({colname, idx}, colnames,
		text_to_set = Eval Insert("^colname^: ^dt[1, colname]^");
		tbs[idx] &amp;lt;&amp;lt; Set Text(text_to_set);
	);
);

nw = New Window( "parameter setting",
	 Panel Box( "parameter setting",
		lub,
		Valuetb = Text Box( "Value: " || Char( Value )),
		sb = Slider Box(
			min, max, Value,
			Valuetb &amp;lt;&amp;lt; set text( "Value: " || Char( Value ));
			:age &amp;lt;&amp;lt; set each value(Value);
			update_tbs;
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Feb 2024 09:19:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721522#M90356</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-02-02T09:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721534#M90357</link>
      <description>&lt;P&gt;Thank you Jarmo, this is exactly what I need&lt;/P&gt;&lt;P&gt;May I ask why you would prefer to move&amp;nbsp;&lt;SPAN&gt;script for Slider Box outside the slider box ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 11:32:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721534#M90357</guid>
      <dc:creator>BayesRabbit7133</dc:creator>
      <dc:date>2024-02-02T11:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721544#M90358</link>
      <description>&lt;P&gt;It gives additional (and fairly easy) layer of separation to your script and it is easier to modify these small blocks of code than the massive new window (you don't have large new window yet but they can quickly get very lengthy). Sometimes it could cause some issues by "losing" the references but I think it is still worth it.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 11:40:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721544#M90358</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-02-02T11:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create different number of text boxes based on variable</title>
      <link>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721545#M90359</link>
      <description>&lt;P&gt;Thank you, I got it.&lt;/P&gt;&lt;P&gt;Also I learned that you use eval insert to replace my original long long functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Always appreciate for your kind sharing&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 11:44:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-different-number-of-text-boxes-based-on-variable/m-p/721545#M90359</guid>
      <dc:creator>BayesRabbit7133</dc:creator>
      <dc:date>2024-02-02T11:44:16Z</dc:date>
    </item>
  </channel>
</rss>

