<?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: How to return value from number edit box for many items in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40067#M23457</link>
    <description>&lt;P&gt;Here is a modified version of the Example taken from&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index==&amp;gt;TextEditBox==&amp;gt;Set Function&lt;/P&gt;
&lt;P&gt;that illustrates the purpose of "{this}"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Example",
	xx = Text Edit Box( "pw?" ),
	Text Box( "" )/* here's the sibling box, waiting to show the pw */
);
xx &amp;lt;&amp;lt; SetFunction(
	Function( {this},
		this &amp;lt;&amp;lt; passwordStyle( 1 );/* hide my display*/ /* put my password into my sibling's display */
		(this &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; settext( this &amp;lt;&amp;lt; getText );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Jun 2017 11:31:35 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-06-07T11:31:35Z</dc:date>
    <item>
      <title>How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/39928#M23380</link>
      <description>&lt;P&gt;Hi JMPers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some problems about the return values of number edit box.&lt;/P&gt;&lt;P&gt;I have referred to other posts(&lt;A href="https://community.jmp.com/t5/Discussions/Combining-Number-Edit-Boxes/m-p/30884" target="_blank"&gt;combining number box&lt;/A&gt;&amp;nbsp;, &lt;A href="https://community.jmp.com/t5/Discussions/How-to-collect-all-data-tables-in-a-new-window/m-p/13834" target="_blank"&gt;collect all data in new window&lt;/A&gt;), and try to create my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I have many items to be given value, typing number into every item is not practical for me.&lt;/P&gt;&lt;P&gt;So the "New Window" and "Append" are used to dispose the return value for many items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eventually the code just return the default value(1) rather than the number I key in.&lt;/P&gt;&lt;P&gt;Can you help to check which steps are wrong in my code?&lt;/P&gt;&lt;P&gt;Thank you for great help in advanced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;list = {"A", "B", "C","D","E","F","G"};
val={};

nw = New Window( "example",
	v = V List Box(),
	Button Box( "OK", Set Script( nw&amp;lt;&amp;lt;close window) )
);

For( i = 1, i &amp;lt;= n items(list), i++,
	(v &amp;lt;&amp;lt; append(
		Outline Box( "",
			H List Box(
				Text Box( list[i] ),
				exq =number Edit Box( 1 ),	
			)
		)
	) ; 
	Insert Into( val, exq&amp;lt;&amp;lt;get);&lt;BR /&gt;    )
);

show(val);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 10:38:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/39928#M23380</guid>
      <dc:creator>WHTseng</dc:creator>
      <dc:date>2017-06-04T10:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/39930#M23382</link>
      <description>&lt;P&gt;The issue you are having, is that you are assuming that each separate specification of "exq" is being retained in a unique instance. &amp;nbsp;What is actually happening, is that they are being written on top of each other. &amp;nbsp;The code below, separates the instances.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
list = {"A", "B", "C", "D", "E", "F", "G"};
val = {};

nw = New Window( "example", v = V List Box(), Button Box( "OK", Set Script( nw &amp;lt;&amp;lt; close window ) ) );

For( i = 1, i &amp;lt;= N Items( list ), i++,
	Insert Into( val, 1 );
	(v &amp;lt;&amp;lt; append(
		Outline Box( "",
			H List Box(
				Text Box( list[i] ),
				Eval(
					Substitute(
							Expr(
								__exq__ = Number Edit Box(
									1,
									10,
									&amp;lt;&amp;lt;SetFunction( Function( {this}, val[__i__] = __exq__ &amp;lt;&amp;lt; get ) )
								)
							),
						Expr( __exq__ ), Parse( "exq" || Char( i ) ),
						Expr( __i__ ), i,
					)
				), 
			)
		)
	) ; );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Jun 2017 12:15:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/39930#M23382</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-04T12:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40064#M23454</link>
      <description>&lt;P&gt;Thank you Jim, that is really a good way and helps me to understand more about "Expr", "substitute, and "Eval".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For&amp;nbsp;&amp;lt;&amp;lt; SetFunction ( Function ( {this} , val[i] = exq &amp;lt;&amp;lt; get ) ),&lt;/P&gt;&lt;P&gt;I guess I can take the "this" away and leave an empty bracket. (I have tried and it still worked)&lt;/P&gt;&lt;P&gt;Will it be any potential risk to keep the bracket empty?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 08:47:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40064#M23454</guid>
      <dc:creator>WHTseng</dc:creator>
      <dc:date>2017-06-07T08:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40067#M23457</link>
      <description>&lt;P&gt;Here is a modified version of the Example taken from&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index==&amp;gt;TextEditBox==&amp;gt;Set Function&lt;/P&gt;
&lt;P&gt;that illustrates the purpose of "{this}"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
New Window( "Example",
	xx = Text Edit Box( "pw?" ),
	Text Box( "" )/* here's the sibling box, waiting to show the pw */
);
xx &amp;lt;&amp;lt; SetFunction(
	Function( {this},
		this &amp;lt;&amp;lt; passwordStyle( 1 );/* hide my display*/ /* put my password into my sibling's display */
		(this &amp;lt;&amp;lt; sib) &amp;lt;&amp;lt; settext( this &amp;lt;&amp;lt; getText );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Jun 2017 11:31:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40067#M23457</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-07T11:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40076#M23462</link>
      <description>&lt;P&gt;Hi Jim,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Really thank you for the professional reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I make my code based on all your suggestions, but I find the problems about sequential execution (the JSL executes all the following&amp;nbsp;codes even if I haven't&amp;nbsp;clicked the "OK" yet).&lt;/P&gt;&lt;P&gt;So I have to put all my following code into Set Script to ensure the correct executive sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are 2 options crossing my mind,&lt;/P&gt;&lt;P&gt;1) Can this method be used in the &amp;lt;&amp;lt;modal? It seems &amp;lt;&amp;lt;modal can stop the JSL running till I click "OK".&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;Does&amp;nbsp;wait(0) work here? and where I should put it among the code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my simplified code to show my problems, I mark 2 lines as blue to show what I have done,&lt;/P&gt;&lt;PRE&gt;Names Default To Here( 1 );
list = {"A", "B", "C", "D", "E", "F", "G"};
val = {};

nw = New Window( "example",
	v = V List Box(),
	Button Box( "OK",
		Set Script(
			nw &amp;lt;&amp;lt; close window;
			&lt;FONT color="#0000FF"&gt;New Window( "result", &amp;lt;&amp;lt;modal, Text Box( val )&lt;/FONT&gt; );
		)
	)
);


For( i = 1, i &amp;lt;= N Items( list ), i++,
	Insert Into( val, 1 );
	(v &amp;lt;&amp;lt; append(
		Outline Box( "",
			H List Box(
				Text Box( list[i] ),
				Eval(
					Substitute(
							Expr(
								exq = Number Edit Box(
									1,
									10,
									&amp;lt;&amp;lt;SetFunction(
										Function( {this},
											val[i] = exq &amp;lt;&amp;lt; get
										)
									)
								)
							),
						Expr( exq ), Parse( "exq" || Char( i ) ),
						Expr( i ), i,

					)
				),

			)
		)
	) ; );
);

&lt;FONT color="#0000FF"&gt;nw2 = New Window( "fake result", &amp;lt;&amp;lt;modal, Text Box( val ) );&lt;/FONT&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 15:07:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40076#M23462</guid>
      <dc:creator>WHTseng</dc:creator>
      <dc:date>2017-06-07T15:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to return value from number edit box for many items</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40084#M23468</link>
      <description>&lt;P&gt;You are correct that JMP will continue processing even without clicking OK. &amp;nbsp;Unless you do 1 of 2 things. &amp;nbsp;Make your display window a "Modal" window&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;nw = New Window("Test Window", Modal, ....................);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will force the processing to wait for the window to be cleared.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Or&lt;/P&gt;
&lt;P&gt;Structure your code into Functions() or Expressions, Expr(), which will not execute the code within them, until expressly called from either your window code, or from another Function() or Expr()&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2017 16:02:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-return-value-from-number-edit-box-for-many-items/m-p/40084#M23468</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-06-07T16:02:29Z</dc:date>
    </item>
  </channel>
</rss>

