cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP Security Notice: CVE-2026-109618 and CVE-2026-109619

    JMP promptly initiated a review of its products, services, and relevant infrastructure for exposure to CVE-2026-109618 and CVE-2026-109619.

    Our assessment of JMP products has not identified exposure to these vulnerabilities. Where remediation was required within supporting environments, appropriate security updates and controls have been applied and validated.

    We have identified no evidence of successful exploitation or unauthorized access to JMP systems or customer information associated with these vulnerabilities.

    JMP continues to monitor the issue and relevant vendor guidance. No action is required by JMP customers at this time.

  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
shuey
Level II

How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?

I'm creating a data table script using New Script() 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 Expr() calls that should only be evaluated when the script actually runs.

 

file_path = "C:\MyData\slopes.jmp";

dt << New Script("Plot Slopes",
    dt_slopes = Open( file_path );
    slope_array = dt_slopes:slope << Get Values;
    
    nw = New Window( "Slope Plots",
        gb = Graph Box()
    );
    
    framebox = gb[Frame Box(1)];
    
    For Each( {slope}, slope_array,
        Eval( Eval Expr(
            framebox << Add Graphics Script(
                Y Function( Expr(slope) * x, x );
            );
        ));
    );
);

The problem: I need file_path to be evaluated and inserted as a literal string when creating the script, but the Expr(slope) inside the For Each loop must remain unevaluated until the script runs (when the user clicks it).

If I wrap everything in Eval(Eval Expr()) to substitute file_path, it also evaluates Expr(slope)prematurely, causing an error since slope doesn't exist yet.

What's the correct approach to selectively evaluate some variables while preserving others for deferred evaluation in stored data table scripts?

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?

One option is to add some Expr(Name Expr()) to your code

Names Default To Here(1);

file_path = "C:\MyData\slopes.jmp";

Eval(EvalExpr(
	dt << New Script(
		"Plot Slopes",
		dt_slopes = Open(Expr(file_path));
		slope_array = dt_slopes:slope << 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 << Add Graphics Script(Y Function(Expr(slope) * x, x))))
		)));
	);
));

When you run only the EvalExpr part you will end up with following script

dt << New Script(
	"Plot Slopes",
	dt_slopes = Open("C:\MyData\slopes.jmp");
	slope_array = dt_slopes:slope << Get Values;
	nw = New Window("Slope Plots", gb = Graph Box());
	framebox = gb[Frame Box(1)];
	For Each({slope}, slope_array,
		Eval(
			Eval Expr(
				framebox << Add Graphics Script(Y Function(Expr(slope) * x, x))
			)
		)
	);
)

jthi_0-1760622928220.png

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?

One option is to add some Expr(Name Expr()) to your code

Names Default To Here(1);

file_path = "C:\MyData\slopes.jmp";

Eval(EvalExpr(
	dt << New Script(
		"Plot Slopes",
		dt_slopes = Open(Expr(file_path));
		slope_array = dt_slopes:slope << 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 << Add Graphics Script(Y Function(Expr(slope) * x, x))))
		)));
	);
));

When you run only the EvalExpr part you will end up with following script

dt << New Script(
	"Plot Slopes",
	dt_slopes = Open("C:\MyData\slopes.jmp");
	slope_array = dt_slopes:slope << Get Values;
	nw = New Window("Slope Plots", gb = Graph Box());
	framebox = gb[Frame Box(1)];
	For Each({slope}, slope_array,
		Eval(
			Eval Expr(
				framebox << Add Graphics Script(Y Function(Expr(slope) * x, x))
			)
		)
	);
)

jthi_0-1760622928220.png

 

-Jarmo
hogi
Level XIII

Re: How to selectively evaluate variables in New Script() while preserving Expr() for deferred evaluation?

nice trick:

expr(name expr())  as a synonym for  protect()


maybe vote here:

2 functions for the 2 meanings of expr() 

Recommended Articles