<?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 selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908094#M106640</link>
    <description>&lt;P&gt;nice trick:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;expr(name expr())&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;as a synonym for&amp;nbsp; &lt;FONT face="courier new,courier"&gt;protect()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;maybe vote here:&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="2 functions for the 2 meanings of expr()" uid="901944" url="https://community.jmp.com/t5/JMP-Wish-List/2-functions-for-the-2-meanings-of-expr/m-p/901944#U901944" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Oct 2025 20:24:59 GMT</pubDate>
    <dc:creator>hogi</dc:creator>
    <dc:date>2025-10-16T20:24:59Z</dc:date>
    <item>
      <title>How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908025#M106632</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I'm creating a data table script using &lt;/SPAN&gt;&lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;New Script()&lt;/CODE&gt;&lt;SPAN&gt; that needs to be evaluated later when a user clicks it. I need to substitute some variables at script-creation time (like a file path) while preserving &lt;/SPAN&gt;&lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;Expr()&lt;/CODE&gt;&lt;SPAN&gt; calls that should only be evaluated when the script actually runs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;file_path = "C:\MyData\slopes.jmp";

dt &amp;lt;&amp;lt; New Script("Plot Slopes",
    dt_slopes = Open( file_path );
    slope_array = dt_slopes:slope &amp;lt;&amp;lt; Get Values;
    
    nw = New Window( "Slope Plots",
        gb = Graph Box()
    );
    
    framebox = gb[Frame Box(1)];
    
    For Each( {slope}, slope_array,
        Eval( Eval Expr(
            framebox &amp;lt;&amp;lt; Add Graphics Script(
                Y Function( Expr(slope) * x, x );
            );
        ));
    );
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P class="whitespace-normal break-words mb-3 last:mb-0"&gt;&lt;STRONG class="font-semibold"&gt;The problem:&lt;/STRONG&gt; I need &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;file_path&lt;/CODE&gt; to be evaluated and inserted as a literal string when creating the script, but the &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;Expr(slope)&lt;/CODE&gt; inside the &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;For Each&lt;/CODE&gt; loop must remain unevaluated until the script runs (when the user clicks it).&lt;/P&gt;
&lt;P class="whitespace-normal break-words mb-3 last:mb-0"&gt;If I wrap everything in &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;Eval(Eval Expr())&lt;/CODE&gt; to substitute &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;file_path&lt;/CODE&gt;, it also evaluates &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;Expr(slope)&lt;/CODE&gt;prematurely, causing an error since &lt;CODE class="before:content-none after:content-none inline px-1.5 py-0.5 mx-0.5 text-sm font-mono bg-muted/70 text-foreground/90 border border-border/40 rounded dark:bg-muted/60 dark:text-foreground/95 dark:border-border/30 font-medium tracking-tight selection:bg-blue-500/30 selection:text-blue-900 dark:selection:bg-blue-500/40 dark:selection:text-blue-50 align-baseline break-words focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2 max-w-full"&gt;slope&lt;/CODE&gt; doesn't exist yet.&lt;/P&gt;
&lt;P class="whitespace-normal break-words mb-3 last:mb-0"&gt;What's the correct approach to selectively evaluate some variables while preserving others for deferred evaluation in stored data table scripts?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 13:38:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908025#M106632</guid>
      <dc:creator>shuey</dc:creator>
      <dc:date>2025-10-16T13:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908040#M106633</link>
      <description>&lt;P&gt;One option is to add some Expr(Name Expr()) to your code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

file_path = "C:\MyData\slopes.jmp";

Eval(EvalExpr(
	dt &amp;lt;&amp;lt; New Script(
		"Plot Slopes",
		dt_slopes = Open(Expr(file_path));
		slope_array = dt_slopes:slope &amp;lt;&amp;lt; Get Values;
		
		nw = New Window("Slope Plots", gb = Graph Box());
		
		framebox = gb[Frame Box(1)];
		
		Expr(Name Expr(For Each({slope}, slope_array,
			Eval(Eval Expr(framebox &amp;lt;&amp;lt; Add Graphics Script(Y Function(Expr(slope) * x, x))))
		)));
	);
));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you run only the EvalExpr part you will end up with following script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; New Script(
	"Plot Slopes",
	dt_slopes = Open("C:\MyData\slopes.jmp");
	slope_array = dt_slopes:slope &amp;lt;&amp;lt; Get Values;
	nw = New Window("Slope Plots", gb = Graph Box());
	framebox = gb[Frame Box(1)];
	For Each({slope}, slope_array,
		Eval(
			Eval Expr(
				framebox &amp;lt;&amp;lt; Add Graphics Script(Y Function(Expr(slope) * x, x))
			)
		)
	);
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1760622928220.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/85194iB5BAE02A7DF077EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1760622928220.png" alt="jthi_0-1760622928220.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 13:55:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908040#M106633</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-16T13:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908094#M106640</link>
      <description>&lt;P&gt;nice trick:&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;expr(name expr())&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;as a synonym for&amp;nbsp; &lt;FONT face="courier new,courier"&gt;protect()&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;maybe vote here:&lt;/P&gt;
&lt;P&gt;&lt;LI-MESSAGE title="2 functions for the 2 meanings of expr()" uid="901944" url="https://community.jmp.com/t5/JMP-Wish-List/2-functions-for-the-2-meanings-of-expr/m-p/901944#U901944" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2025 20:24:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-selectively-evaluate-variables-in-New-Script-while/m-p/908094#M106640</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2025-10-16T20:24:59Z</dc:date>
    </item>
  </channel>
</rss>

