<?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: treat variable within &amp;quot;&amp;lt;&amp;lt; set formula&amp;quot; Formula as constant/literal in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34357#M20360</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;blockSize = 15;

Eval(
	Substitute(
		Expr( col &amp;lt;&amp;lt; Set Formula( Sequence( 1, 1000, 1, bbb ) ) ),
		Expr( bbb ),
		blockSize
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Jan 2017 17:41:29 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2017-01-11T17:41:29Z</dc:date>
    <item>
      <title>JSL: treat variable within "&lt;&lt; set formula" Formula as constant/literal</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34356#M20359</link>
      <description>&lt;P&gt;I feel like there should be an easy way to do this but it is eluding me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE&gt;blockSize = 15;
col&amp;lt;&amp;lt;set formula(Sequence(1,1000,1,blockSize));&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After running script, view formula in datatable -- "blockSize" is still being used as the fourth input for Sequence().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't really want this, as I'm going to dynamically define blockSize inside a loop that changes for each column it iterates through. How do I get the datatable's formula to be "Sequence(1,1000,1,15)" instead of "Sequence(1,1000,1, blockSize)"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 17:35:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34356#M20359</guid>
      <dc:creator>ABI</dc:creator>
      <dc:date>2017-01-11T17:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: treat variable within "&lt;&lt; set formula" Formula as constant/literal</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34357#M20360</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;blockSize = 15;

Eval(
	Substitute(
		Expr( col &amp;lt;&amp;lt; Set Formula( Sequence( 1, 1000, 1, bbb ) ) ),
		Expr( bbb ),
		blockSize
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Jan 2017 17:41:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34357#M20360</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-01-11T17:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: treat variable within "&lt;&lt; set formula" Formula as constant/literal</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34376#M20367</link>
      <description>&lt;P&gt;&amp;nbsp;Somes I like to use command strings with variable replacement, especially when I need to use the same command more than once, and if the formula or expression has more than one variable.&lt;/P&gt;&lt;PRE&gt;dt = New Table( "Testit",
	Add Rows( 1500 ),
	New Column( "bbb", Numeric, "Continuous", Format( "Best", 12 ), ),
	New Column( "ccc", Numeric, "Continuous", Format( "Best", 12 ), ), 

);

cmdStr = "^curcol^ &amp;lt;&amp;lt; set formula(Sequence(1,1000,1,^blocksize^));";

curcol = ":bbb";
blocksize = 15;
eval(parse(evalInsert(cmdStr)));
// Eval Insert substitutes the variable values delimited by ^
// Parse converts the string to an expression
// Eval runs the expression
// uncomment the next line to see results of evalInsert  
// show(evalInsert(cmdStr) );

//==can reuse===
curcol =":ccc" ;
blocksize = 5;
eval(parse(evalInsert(cmdStr)));

&lt;/PRE&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>Wed, 11 Jan 2017 20:43:25 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34376#M20367</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2017-01-11T20:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: JSL: treat variable within "&lt;&lt; set formula" Formula as constant/literal</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34408#M20379</link>
      <description>&lt;P&gt;One more approach using the eval(evalexpr( ... expr( x ) ... )) pattern&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=newtable("example", newcolumn("col"));
blockSize = 15;
&lt;STRONG&gt;eval&lt;/STRONG&gt;(&lt;STRONG&gt;evalexpr&lt;/STRONG&gt;(col&amp;lt;&amp;lt;set formula(Sequence(1,1000,1,&lt;STRONG&gt;expr&lt;/STRONG&gt;(blockSize)))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Formula with blocksize value substituted for the variable" style="width: 483px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/4770i48223F0B2AF8C7F8/image-size/large?v=v2&amp;amp;px=999" role="button" title="formula.PNG" alt="Formula with blocksize value substituted for the variable" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Formula with blocksize value substituted for the variable&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The problem all of these solutions are solving is pre-evaluating part of the expression, but not all of it.&lt;/P&gt;
&lt;P&gt;EvalExpr() is a function that partially evaluates its argument. The parts that you want evaluated are inside Expr() functions. (Thus the name, EvalExpr.) The result is an expression, which needs to be evaluated to perform the setFormula operation.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 14:45:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-treat-variable-within-quot-lt-lt-set-formula-quot-Formula-as/m-p/34408#M20379</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-01-12T14:45:29Z</dc:date>
    </item>
  </channel>
</rss>

