<?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 Convert script variable to static value in New Column formula in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Convert-script-variable-to-static-value-in-New-Column-formula/m-p/875637#M103902</link>
    <description>&lt;P&gt;Hello, I was writing some JSL to process a source file, and hoping to reuse/adapt the source file.&amp;nbsp; To that end I created a few very simple variables that I intended to change only occasionally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a short section of JSL that creates variables and uses them in a column formula.&amp;nbsp; These are not the original names.&amp;nbsp; I changed to keep it simple:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP v18.2.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

VariableA = 42; // A value I intend to change occasionally depending on the details of the source data

VariableB = 1; // Another value I'll change depending on the source data.

&amp;nbsp; &amp;nbsp; dt &amp;lt;&amp;lt; New Column( "A_New_Formula_Coumn",
&amp;nbsp; &amp;nbsp; numeric,
&amp;nbsp; &amp;nbsp; ordinal,
&amp;nbsp; &amp;nbsp; Formula( :An_Existing_Data_Column - VariableA * VariableB )
&amp;nbsp; &amp;nbsp; );

 &amp;nbsp; dt &amp;lt;&amp;lt; New Column( "A_Simpler_New_Formula_Coumn",
&amp;nbsp; &amp;nbsp; numeric,
&amp;nbsp; &amp;nbsp; ordinal,
&amp;nbsp; &amp;nbsp; Formula( :An_Existing_Data_Column - 42 )
&amp;nbsp; &amp;nbsp; );&lt;/CODE&gt;&lt;/PRE&gt;
I've run this in an external script and from a script in the table.&amp;nbsp; Both seem to have no trouble when the script is first run.&amp;nbsp; The problem is that "VariableA" and "VariableB" are used in the column formula, almost as if they are local variables.&amp;nbsp; But they aren't defined anywhere.&amp;nbsp; So when I close JMP down completely and reopen it - only then do I get a warning that there is something wrong with the formula:&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MeanChris_0-1747947050994.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76128i9A21329F8ABC22BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MeanChris_0-1747947050994.png" alt="MeanChris_0-1747947050994.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really just want the script to apply THIS formula to the new column, i.e. evaluate the script variable portion.&amp;nbsp; But I don't know how to do that.&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MeanChris_1-1747947120991.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76129i01E7AEAF6CB31E32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MeanChris_1-1747947120991.png" alt="MeanChris_1-1747947120991.png" /&gt;&lt;/span&gt;
&lt;P&gt;I'd prefer NOT to use table variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reading!&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Thu, 22 May 2025 20:58:08 GMT</pubDate>
    <dc:creator>MeanChris</dc:creator>
    <dc:date>2025-05-22T20:58:08Z</dc:date>
    <item>
      <title>Convert script variable to static value in New Column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-script-variable-to-static-value-in-New-Column-formula/m-p/875637#M103902</link>
      <description>&lt;P&gt;Hello, I was writing some JSL to process a source file, and hoping to reuse/adapt the source file.&amp;nbsp; To that end I created a few very simple variables that I intended to change only occasionally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a short section of JSL that creates variables and uses them in a column formula.&amp;nbsp; These are not the original names.&amp;nbsp; I changed to keep it simple:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;JMP v18.2.0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();

VariableA = 42; // A value I intend to change occasionally depending on the details of the source data

VariableB = 1; // Another value I'll change depending on the source data.

&amp;nbsp; &amp;nbsp; dt &amp;lt;&amp;lt; New Column( "A_New_Formula_Coumn",
&amp;nbsp; &amp;nbsp; numeric,
&amp;nbsp; &amp;nbsp; ordinal,
&amp;nbsp; &amp;nbsp; Formula( :An_Existing_Data_Column - VariableA * VariableB )
&amp;nbsp; &amp;nbsp; );

 &amp;nbsp; dt &amp;lt;&amp;lt; New Column( "A_Simpler_New_Formula_Coumn",
&amp;nbsp; &amp;nbsp; numeric,
&amp;nbsp; &amp;nbsp; ordinal,
&amp;nbsp; &amp;nbsp; Formula( :An_Existing_Data_Column - 42 )
&amp;nbsp; &amp;nbsp; );&lt;/CODE&gt;&lt;/PRE&gt;
I've run this in an external script and from a script in the table.&amp;nbsp; Both seem to have no trouble when the script is first run.&amp;nbsp; The problem is that "VariableA" and "VariableB" are used in the column formula, almost as if they are local variables.&amp;nbsp; But they aren't defined anywhere.&amp;nbsp; So when I close JMP down completely and reopen it - only then do I get a warning that there is something wrong with the formula:&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MeanChris_0-1747947050994.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76128i9A21329F8ABC22BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MeanChris_0-1747947050994.png" alt="MeanChris_0-1747947050994.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really just want the script to apply THIS formula to the new column, i.e. evaluate the script variable portion.&amp;nbsp; But I don't know how to do that.&lt;/P&gt;
&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MeanChris_1-1747947120991.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/76129i01E7AEAF6CB31E32/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MeanChris_1-1747947120991.png" alt="MeanChris_1-1747947120991.png" /&gt;&lt;/span&gt;
&lt;P&gt;I'd prefer NOT to use table variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reading!&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 22 May 2025 20:58:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-script-variable-to-static-value-in-New-Column-formula/m-p/875637#M103902</guid>
      <dc:creator>MeanChris</dc:creator>
      <dc:date>2025-05-22T20:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert script variable to static value in New Column formula</title>
      <link>https://community.jmp.com/t5/Discussions/Convert-script-variable-to-static-value-in-New-Column-formula/m-p/875732#M103907</link>
      <description>&lt;P&gt;You will have to evaluate them&amp;nbsp;&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

myvar = 100;

Eval(EvalExpr(
	dt &amp;lt;&amp;lt; new column("A", Numeric, Continuous, Formula(
		:height * Expr(myvar)
	));
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 04:10:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Convert-script-variable-to-static-value-in-New-Column-formula/m-p/875732#M103907</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-05-23T04:10:09Z</dc:date>
    </item>
  </channel>
</rss>

