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
BayesRabbit7133
Level III

Use JSL to set different formula in each row

Hi JMP experts,

Somehow I think my post just got deleted, post it again

 

I have a DOE table with many predicted formula, these formulae have X, Y axis relationship

I would like to rearrange data table into below format so that I can draw surface plot (X, Y, Value) to see how it changes as  I change parameter

BayesRabbit7133_0-1706604162914.png

Two issues:

1. I can get formulae then concate to below format if ( row == 1, formula 1, if( row == 2, formula 2, ......etc)

 But eventually the formula is a long char with "", I need to manully remove "' for the formula to work

 

2. I use H list box to get value and set each row to change parameters, so that I can see how surface plot changes. But ideally I would like to use scorll bar to change the parameter so that I can see the changes more smoothly

 

 

dt = data table("example DOE table");
dt2 = current data table();
colname = dt << get column names();
colnamelist = {};
formulalist = {};
loopword = char("If( Row() == ");
mid = char("");
final = char("");

//Get column names with predicted formula
for (i = 1, i <= N items(colname),i++,
	pos = Contains (colname[i], "Pred F");
	if(pos == 1 , insert into(colnamelist, colname[i]), continue())
);

//Get formula from columns and save into list
for each({colval}, colnamelist,
	eval(evalexpr(
		formula  = Char(Expr(Name Expr(As Column(dt,colval))) << get formula());		
	));
	insert into (formulalist, formula)
);

//Concat formulas to below format: If( row == 1, Formula 1, If( row ==2, Forumla 2, If( row == 3, formula 3)))......etc
for (i=1, i <= N rows() , i++,
	mid = mid || loopword || char(i) || ", " || char(formulalist[i]) || ", "	
);

final = mid || char("0");

for (i=1, i <= N rows() , i++,
	final = final || char(")")
);

eval(evalexpr(
	:height << set formula(expr(final))
));

nw = New Window( "process paramaeter setting",
	H List Box( Text Box( "   Input Parameter A " ), A = Number Edit Box() ),
	H List Box( Text Box( "   Input Parameter B " ), B = Number Edit Box() ),
	H List Box( Text Box( "   Input Parameter C " ), C = Number Edit Box() ),
	H List Box( Text Box( "   Input Parameter D " ), D = Number Edit Box() ),
	Button Box( "OK",
		theA = A << get;
		theB = B << get;
		theC = C << get;
		theD = D << get;

		:Parameter A << set each value(theA);
		:Parameter B << set each value(theB);
		:Parameter C << set each value(theC);
		:Parameter D << set each value(theD);
	    //Somehow the column with formula cannot draw into surface plot directly, so I have to copy and paste value to anohter column to draw
		newheight = :height << get values;
		:newheight<< set values(newheight);
	)
)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Use JSL to set different formula in each row

look in the Scripting Index for the Slider Box() and you will see:

Syntax: box = Slider Box(min Value, max Value, variable, SCRIPT, <set width(n)>, <rescale slider(min Value, max Value)< )

You can take the JSL from your OK button and place it into the definition of the Slider Box().  It will be executed every time the slider is moved.

Jim

View solution in original post

5 REPLIES 5
BayesRabbit7133
Level III

Re: Use JSL to set different formula in each row

I found it, a simple parse() can do the trick for my first question

seval(evalexpr(
	:height << set formula(expr(parse(final)))
));

But for the second question, it would be really nice if we can have scroll bar to set each value  so that user can easily review how 3D map changes as the parameter changes,  

txnelson
Super User

Re: Use JSL to set different formula in each row

It sounds like you need to use Slider Boxes for your input, rather than the Number Edit Boxes

Jim
BayesRabbit7133
Level III

Re: Use JSL to set different formula in each row

Thank you Jim, a slider box is what I'm looking for.

But one more thing, I create a buttom box to get the value from slider box then set each value to change rows, is it possible to make the row real time change as the slider, without additional check buttom?

Value = 0;
New Window( "Example",
	Panel Box( "Parameter setting",
		tb = Text Box( "Parameter A: " || Char( Value ) ),
		sb = Slider Box( 0, 1, Value, tb << Set Text( "Value: " || Char( Value ) ) ),
		Button Box( "OK",
		:Parameter A << set each value(Value)
		)	
	)
);

 

 

txnelson
Super User

Re: Use JSL to set different formula in each row

look in the Scripting Index for the Slider Box() and you will see:

Syntax: box = Slider Box(min Value, max Value, variable, SCRIPT, <set width(n)>, <rescale slider(min Value, max Value)< )

You can take the JSL from your OK button and place it into the definition of the Slider Box().  It will be executed every time the slider is moved.

Jim
BayesRabbit7133
Level III

Re: Use JSL to set different formula in each row

This perfectly resolved my issue, thank you Jim for your support