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
tmj
tmj
Level II

Saving New Script to data table from expression

Hello...I want to be able to create several Variability Charts in a window from a list that contains column names. I can get this to run successfully in real time (thanks to help from other JMP forum posts). But I also want to save script to the data table so that next time the data table is opened the user can just click on the "green triangle" to generate the same window of plots. I'm coming close, it is saving something to the data table, but will not generate the window with plots on click of the green triangle. If I right click and select Edit on the green triangle I can see that the reason it will not produce the window with plots is because the entire script is in quotes. I can't figure out how to remove the quotes. Any ideas?

 

1st I build string (plotAllStandardExpr) to build the new window through a series of concatenations within a for loop. 

2nd the line Eval(Parse(plotAllStandardExpr)) will successfully create the window with all the plots in it.

But the Eval(Substitute(....) line is just saving the quoted string to the data table. I tried Eval(Parse(plotAllStandardExpr)) within the Substitute function but that did not work.

 

Current Data Table(dtSplit_copy);
plotAllStandardExpr = "New Window(\!"Var Charts: All\!", V List Box(";
for(i = 1, i <= NItems(plotcols), i++,
	plotAllStandardExpr = plotAllStandardExpr || "Variability Chart(
				Y(" || plotcolsString[i] || "),
				X( :Split, :Voltage, :tst_temp ),
				Std Dev Chart( 0 ),
				Points Jittered( 1 ),
				Show Box Plots( 1 ));"
	
);
plotAllStandardExpr = plotAllStandardExpr ||"))";

Eval(Parse(plotAllStandardExpr));

Eval(Substitute(Expr(dtSplit_copy << New Script("All Var charts", xxxx)), 
	Expr(xxxx), Eval(plotAllStandardExpr)));

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Saving New Script to data table from expression

You need to use Parse() to remove the quotes (no need for Eval() as you want the expression). Below are few options

Names Default To Here(1);

dt = New Table("");

plotcolsString = {"height", "weight"};

plotAllStandardExpr = "New Window(\!"Var Charts: All\!", V List Box(";
For(i = 1, i <= N Items(plotcolsString), i++,
	plotAllStandardExpr = plotAllStandardExpr || "Variability Chart(
				Y(" || plotcolsString[i]
	 ||
	"),
				X( :Split, :Voltage, :tst_temp ),
				Std Dev Chart( 0 ),
				Points Jittered( 1 ),
				Show Box Plots( 1 ))
	,"
	
);
plotAllStandardExpr = plotAllStandardExpr || "))";

Parse(plotAllStandardExpr);

Eval(EvalExpr(dt << New Script("all var charts", Expr(Parse(plotAllStandardExpr)))));

Eval(Substitute(
	Expr(dt << New Script("All Var charts2", _script_)),
	Expr(_script_), Parse(plotAllStandardExpr))
);

jthi_0-1683777982775.png

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Saving New Script to data table from expression

You need to use Parse() to remove the quotes (no need for Eval() as you want the expression). Below are few options

Names Default To Here(1);

dt = New Table("");

plotcolsString = {"height", "weight"};

plotAllStandardExpr = "New Window(\!"Var Charts: All\!", V List Box(";
For(i = 1, i <= N Items(plotcolsString), i++,
	plotAllStandardExpr = plotAllStandardExpr || "Variability Chart(
				Y(" || plotcolsString[i]
	 ||
	"),
				X( :Split, :Voltage, :tst_temp ),
				Std Dev Chart( 0 ),
				Points Jittered( 1 ),
				Show Box Plots( 1 ))
	,"
	
);
plotAllStandardExpr = plotAllStandardExpr || "))";

Parse(plotAllStandardExpr);

Eval(EvalExpr(dt << New Script("all var charts", Expr(Parse(plotAllStandardExpr)))));

Eval(Substitute(
	Expr(dt << New Script("All Var charts2", _script_)),
	Expr(_script_), Parse(plotAllStandardExpr))
);

jthi_0-1683777982775.png

 

-Jarmo
tmj
tmj
Level II

Re: Saving New Script to data table from expression

Thanks very much. Both options worked as advertised!