cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar

How to get script from a plot and save to the data table in JSL script?

I am trying to extract the script from a plot and save it to the data table for future use.

 

Below is my script for the "Analgesics" table from the "Sample Data Library", which doesn't work as I hoped.

The "print(dtp_script)" line shows the correct script.

However, the actual "plot_dt1" script saved in the data table contains only the "dtp_script" variable name, instead of the actual script. How do I save the actual script in the data table? Thanks!

 

dt = current data table ();
dtplot = dt << Fit Group( Oneway( Y( :pain ), X( :gender ) ),
	Oneway( Y( :pain ), X( :drug ) ),
	<<{Arrange in Rows( 2 )} );
dtp_script = dtplot << get script;
print (dtp_script);
dt << new script("plot_dt1", dtp_script );
1 ACCEPTED SOLUTION

Accepted Solutions
Jasean
Staff

Re: How to get script from a plot and save to the data table in JSL script?

If you use NameExpr(dtp_script), it will return the expression referenced by dtp_script.  You can then put that in place of "dtp_script" in your last statement.  However, to do that, you will need to get JMP to evaluate NameExpr(dtp_script) before it sends the new script message to the data table.  Your last statement should look like this:

Eval(
	EvalExpr(
		dt << New Script("plot_dt1", Expr(Name Expr(dtp_script)))
	)
)

For the argument of EvalExpr(), anything that is inside an Expr() gets evaluated in place.  EvalExpr() returns an expression with the evaluated value replacing Expr(...).  In this case, the expression referenced by dtp_script.  I hope this is clear.  You can read more about expression manipulation in the Scripting Index (Help -> Scripting Index) or the Scripting Guide (Help -> JMP Documentation Library).

 

View solution in original post

2 REPLIES 2
Jasean
Staff

Re: How to get script from a plot and save to the data table in JSL script?

If you use NameExpr(dtp_script), it will return the expression referenced by dtp_script.  You can then put that in place of "dtp_script" in your last statement.  However, to do that, you will need to get JMP to evaluate NameExpr(dtp_script) before it sends the new script message to the data table.  Your last statement should look like this:

Eval(
	EvalExpr(
		dt << New Script("plot_dt1", Expr(Name Expr(dtp_script)))
	)
)

For the argument of EvalExpr(), anything that is inside an Expr() gets evaluated in place.  EvalExpr() returns an expression with the evaluated value replacing Expr(...).  In this case, the expression referenced by dtp_script.  I hope this is clear.  You can read more about expression manipulation in the Scripting Index (Help -> Scripting Index) or the Scripting Guide (Help -> JMP Documentation Library).

 

Re: How to get script from a plot and save to the data table in JSL script?

Thank you! This is very helpful!