cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
neelsrejan
Level III

Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

Hi all,

 

I am a bit confused as to why the table script does not dynamically consider the variable set in the main script. As such the figures are getting standard values rather than dynamic selections based on the for loop's run. Any help would be appreciated. Below is the table script I am referring to in case that it's not commonly called the table script.

Screenshot 2024-11-14 013952.png

Please take a look at the main JSL script on the left in which the highlighted code works dynamically. When the "vc script" is saved to the data table, the script opens up to the right side of the screenshot. It seems like the first value that "weights" and "counts" encounters is set for all each loop of the for loop that its embedded in. Is there a way to make this dynamic? I have only read posts about making columns strings or a formula but I don't think that fits this case. 

Screenshot 2024-11-14 013723.png

Any help would be appreciated to alter the main jsl code such that the saved script does not hard code these values. Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

If I understand correctly, you want to prevent the evaluation of some of the variables. One option to do this is to use multiple Expr().

 

As you didn't share the script, I will try to use very simple example which hopefully demonstrates what you can do. Compare the script, table script and script which is inside frame box

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(525, 454),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height)),
	Elements(Points(X, Y, Legend(3)))
);


script = EvalExpr(
	vals = [55, 60, 70];
	Eval(EvalExpr(
		Current Report()[FrameBox(1)] << Add Graphics Script(
			Local({myvals = Expr(Expr(Expr(vals)))},
				Pen Size(1);
				Line Style(1);
				For(i = 1, i <= N Items(Expr(Expr(Expr(vals)))), i++,
					H Line(Expr(Expr(Expr(vals))));
				);				
			);
		);
	))
);

Eval(EvalExpr(
	dt << New Script("Test", Expr(Name Expr(script)));
));

jthi_1-1731648619087.png

jthi_2-1731648631946.png

 

 

-Jarmo

View solution in original post

6 REPLIES 6
jthi
Super User

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

Are there some specific values you wish to evaluate but not all in your vc script?

-Jarmo
neelsrejan
Level III

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

From the top left, I create a subsetted data table "vc depo summary subset" that per each for loop subsets by a variable in this case depo but for the sake of an example: depo = {"A", "B", "C"}. In the jsl script on the left, subsetting by A gives weights = [50, 50, 50, 50, 50] and counts = [16, 20, 19, 20, 20] and subsetting by B or C give different weights and counts. The script on the left works properly. But when I open the same script that is saved to the data table, it defaults weights/counts to the values of A instead of leaving the variable (as it is on the left) which carries the correct weights/counts for B and C respectively. I am unsure how to keep it as a variable rather than seeing the hard coded values on the right.

jthi
Super User

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

If I understand correctly, you want to prevent the evaluation of some of the variables. One option to do this is to use multiple Expr().

 

As you didn't share the script, I will try to use very simple example which hopefully demonstrates what you can do. Compare the script, table script and script which is inside frame box

Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

gb = dt << Graph Builder(
	Size(525, 454),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height)),
	Elements(Points(X, Y, Legend(3)))
);


script = EvalExpr(
	vals = [55, 60, 70];
	Eval(EvalExpr(
		Current Report()[FrameBox(1)] << Add Graphics Script(
			Local({myvals = Expr(Expr(Expr(vals)))},
				Pen Size(1);
				Line Style(1);
				For(i = 1, i <= N Items(Expr(Expr(Expr(vals)))), i++,
					H Line(Expr(Expr(Expr(vals))));
				);				
			);
		);
	))
);

Eval(EvalExpr(
	dt << New Script("Test", Expr(Name Expr(script)));
));

jthi_1-1731648619087.png

jthi_2-1731648631946.png

 

 

-Jarmo
neelsrejan
Level III

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

Thanks Jarmo, that worked!

 

Is there a reason we have to triple encase the variable with three Expr() functions instead of just 1?

jthi
Super User

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

Yes as this is just how expression evaluation on JMP works ( Scripting Guide > Programming Methods > Advanced Expressions, Macros, and Lists "Quoting and Unquoting Expressions").

 

In this case you two have EvalExpr when building the expression which will evaluate two of them AND you wish to leave one extra for the table script so it is kept as Expr instead of being evaluated (so we need three in total). There are other ways of building things like this, but it is good to learn how adding more Expr() can sometimes be helpful.

 

I think for example this should result in similar script without needing triple Expr()

 

script = Substitute(
	Expr(
		vals = [55, 60, 70];
		Eval(
			Eval Expr(
				Current Report()[FrameBox(1)] << Add Graphics Script(
					Local({myvals = _valsexpr_},
						Pen Size(1);
						Line Style(1);
						For(i = 1, i <= N Items(_valsexpr_), i++,
							H Line(_valsexpr_)
						);
					)
				)
			)
		);
	),
	Expr(_valsexpr_), Name Expr(Expr(vals))
);

 

 

 

-Jarmo
hogi
Level XII

Re: Data Table Script not dynamically not updating to use new value in saved script but works from the main jsl script

Why not just 

script = Expr(
	vals = [55, 60, 70];
	Eval(EvalExpr(
		Current Report()[FrameBox(1)] << Add Graphics Script(
			Local({myvals = Expr(vals)},
				Pen Size(1);
				Line Style(1);
				For(i = 1, i <= N Items(Expr(vals)), i++,
					H Line(Expr(vals));
				);				
			);
		);
	))
);

?