<?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: JSL button box: fix variables at time of button creation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-button-box-fix-variables-at-time-of-button-creation/m-p/220290#M44058</link>
    <description>&lt;P&gt;Using Eval(EvalExpr()) or Eval(Substitute()) will let you make runtime variables static.&amp;nbsp; Check the scripting index for examples how to use them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

RepGen = function({btn_name}, 
	{DEFAULT LOCAL},
	print(btn_name);
);

vlb = Vlistbox();
btns = {"Btn 1", "Other", "Button 2 (or3)"};

for(i=1, i&amp;lt;=nitems(btns), i++, 
	vlb &amp;lt;&amp;lt; Append(
		Eval(
			//run just this block to show that the buttons are getting evaluated at creation time
			EvalExpr(
				Buttonbox(btns[i], RepGen(Expr(btns[i])))//the expr will evaluate inside the evalexpr
			)
		)
	)
);
new window("Test", 
	vlb
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Aug 2019 23:37:17 GMT</pubDate>
    <dc:creator>vince_faller</dc:creator>
    <dc:date>2019-08-06T23:37:17Z</dc:date>
    <item>
      <title>JSL button box: fix variables at time of button creation</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-button-box-fix-variables-at-time-of-button-creation/m-p/220244#M44054</link>
      <description>&lt;P&gt;My script creates a list of buttons using a for loop. each button calls a function "RepGen" which needs the button's name for an input. The button's behavior doesn't seem to be evaluated until the button is pressed though, at which time the for loop has overwritten the variable containing the button name. Is there a way to evaluate this variable at the time the button is created instead of when it is pressed? Or is there a better way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dtSum = dt &amp;lt;&amp;lt; Summary( Group( :ColX ) );
For( i = 1, i &amp;lt;= N Rows( dtSum ), i++,
	varName = dtSum:ColX[i];
	obparts &amp;lt;&amp;lt; append( Button Box( varName, RepGen( varName ) ) );
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 19:22:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-button-box-fix-variables-at-time-of-button-creation/m-p/220244#M44054</guid>
      <dc:creator>CaseyL</dc:creator>
      <dc:date>2019-08-06T19:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSL button box: fix variables at time of button creation</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-button-box-fix-variables-at-time-of-button-creation/m-p/220290#M44058</link>
      <description>&lt;P&gt;Using Eval(EvalExpr()) or Eval(Substitute()) will let you make runtime variables static.&amp;nbsp; Check the scripting index for examples how to use them.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here( 1 );

RepGen = function({btn_name}, 
	{DEFAULT LOCAL},
	print(btn_name);
);

vlb = Vlistbox();
btns = {"Btn 1", "Other", "Button 2 (or3)"};

for(i=1, i&amp;lt;=nitems(btns), i++, 
	vlb &amp;lt;&amp;lt; Append(
		Eval(
			//run just this block to show that the buttons are getting evaluated at creation time
			EvalExpr(
				Buttonbox(btns[i], RepGen(Expr(btns[i])))//the expr will evaluate inside the evalexpr
			)
		)
	)
);
new window("Test", 
	vlb
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 23:37:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-button-box-fix-variables-at-time-of-button-creation/m-p/220290#M44058</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2019-08-06T23:37:17Z</dc:date>
    </item>
  </channel>
</rss>

