cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
SDF1
Super User

JSL: Help with strange behavior for New Script command

Hello Scripters,

 

(W11, 64-bit, JMP Pro 18.1.1)

 

  I'm having some strange behavior with a script that I'm running. The script does several things, but one thing that it does is to create some new scripts to add to the data table. I have to pass some variables to the New Script and have it run in the data table outside of the original JSL. I am adding two new scripts to the data table. One is for visualizing the data with Graph Builder (it works just fine), the other is visualizing the data with the Distribution platform.

 

  Here is the JSL that adds the Graph Builder script (it works great, does exactly what I want it to):

Eval(
		Eval Expr(
			DOETable << New Script(
				"Visualize Graphic Results",
				Current Data Table()<<Graph Builder(
					Size( 1022, 727 ),
					Variables(
						X( Expr( Column( DOETable, 1 ) ) ),
						Y( Expr( Column( DOETable, 2 * Eval( (npreds + 1) ) ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) + 1 ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) + 2 ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) + 3 ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) + 4 ) ) ),
						Y( Expr( Column( DOETable, N Items( ListNames ) + 5 ) ) )
					),
					Elements( Position( 1, 1 ), Points( X, Y, Legend( 55 ) ) ),
					Elements( Position( 1, 2 ), Points( X, Y, Legend( 56 ) ) ),
					Elements( Position( 1, 3 ), Points( X, Y, Legend( 57 ) ) ),
					Elements( Position( 1, 4 ), Points( X, Y, Legend( 58 ) ) ),
					Elements( Position( 1, 5 ), Points( X, Y, Legend( 59 ) ) ),
					Elements( Position( 1, 6 ), Points( X, Y, Legend( 60 ) ) ),
					Elements( Position( 1, 7 ), Points( X, Y, Legend( 61 ) ) )
				)
			)
		)
	);

Similarly, here is the script for the Distribution visualization, which doesn't work as intended:

Eval(
		Eval Expr(
			DOETable << New Script(
				"Visualize Distribution Results",
				Current Data Table()<<Distribution(
					Continuous Distribution( Expr( Column( DOETable, 2 * Eval( (npreds + 1) ) ) ) ),
					Process Capability( 0 ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) ) ), Process Capability( 0 ) ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) + 1 ) ), Process Capability( 0 ) ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) + 2 ) ), Process Capability( 0 ) ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) + 3 ) ), Process Capability( 0 ) ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) + 4 ) ), Process Capability( 0 ) ),
					Continuous Distribution( Expr( Column( DOETable, N Items( ListNames ) + 5 ) ), Process Capability( 0 ) ),
					SendToReport(
						Dispatch( {Expr(ListNames[NItems(Ycols)+1])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+2])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+3])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+4])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+5])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+6])}, "Quantiles", OutlineBox, {Close( 1 )} ),
						Dispatch( {Expr(ListNames[NItems(Ycols)+7])}, "Quantiles", OutlineBox, {Close( 1 )} )
					)
				)
			)
		)
	);

  When I run the parent script, the two new table scripts are added (again the GB script works just fine), but when I try to run the Distribution script from the data table (green triangle), instead of showing the results, it opens up the Distribution platform window.

SDF1_0-1749735408022.png

SDF1_2-1749735475257.png

NOTE: names have been removed to protect the innocent ;-).

 

  First off, it shouldn't do this, it should actually bring up all the distributions as laid out in the new script (when I run the script stepwise in the parent JSL, it works).

 

  Here's the very strange part. If I open up the new script in the data table (Edit Script), and click Run, it works exactly as intended.

SDF1_3-1749735688131.pngSDF1_4-1749736010450.png

 

  I can't figure out what I'm doing wrong -- the JSL works, but for whatever reason, when I try to run it from the green triangle, it doesn't work, which doesn't make sense to me. Have I missed something or have a wrong call/command somewhere? Have others come across this strange behavior, and if so, how did you get around it?

 

  Any help is much appreciated, thanks!

 

DS

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SDF1
Super User

Re: JSL: Help with strange behavior for New Script command

Hi @Craige_Hales and @jthi ,

 

  Actually, the problem was a bit of a mix of both. For one, the Column() call should not have been in the Expr() call. Two, the proper reference to the column for the Distribution platform needed to be used, but because I'm saving this as a data table script within the parent JSL, I can't just refence the column as :"name"n, I have to build that within and Eval Insert(), and also Parse() it within and Expr() call.

 

  What ended up working for the Distribution platform was the following:

	Eval(
		Eval Expr(
			Distribution(
				Continuous Distribution( Column( Expr( Parse( Eval Insert( ":\!"^ListNames[Nitems(YCols)+1]^\!"" || "n" ) ) ) ) ),
				Process Capability( 0 )
			)
		)
	);

  This built the proper column name reference for the Distribution platform and allowed for an executable script that could be saved to the data table. A bit cumbersome in my opinion, but it works, and that's what matters.

 

Thanks for your suggestions!

DS

View solution in original post

3 REPLIES 3
jthi
Super User

Re: JSL: Help with strange behavior for New Script command

My first guess is the usage of Column().

 

Distribution platform has horribly named argument "Column". Notice how columns are inputted here

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
obj = dt << Distribution(Column(:Age, :Weight));

compared to graph builder

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = Graph Builder(
	Variables(X(:height), Y(:weight)),
	Elements(Points(X, Y), Smoother(X, Y))
);
View more...
Column() isn't used with Graph builder it uses X(), Y() and so on
-Jarmo
Craige_Hales
Super User

Re: JSL: Help with strange behavior for New Script command

I think you are probably right. The evalexpr is going to try to turn the platform's column syntax into a column. It might work this way:

 Expr( Column( DOETable, N Items( ListNames ) ) )
//becomes (untested...)
 Column( Expr(DOETable), expr( N Items (ListNames ) ) )

The syntax for each platform often uses that function-like structure for grouping, and when the name the platform uses is the same as a function name it is confusing. You'd still need to rearrange because the expr needs to be something that will evaluate to a constant that can be inserted into the expression.

Craige
SDF1
Super User

Re: JSL: Help with strange behavior for New Script command

Hi @Craige_Hales and @jthi ,

 

  Actually, the problem was a bit of a mix of both. For one, the Column() call should not have been in the Expr() call. Two, the proper reference to the column for the Distribution platform needed to be used, but because I'm saving this as a data table script within the parent JSL, I can't just refence the column as :"name"n, I have to build that within and Eval Insert(), and also Parse() it within and Expr() call.

 

  What ended up working for the Distribution platform was the following:

	Eval(
		Eval Expr(
			Distribution(
				Continuous Distribution( Column( Expr( Parse( Eval Insert( ":\!"^ListNames[Nitems(YCols)+1]^\!"" || "n" ) ) ) ) ),
				Process Capability( 0 )
			)
		)
	);

  This built the proper column name reference for the Distribution platform and allowed for an executable script that could be saved to the data table. A bit cumbersome in my opinion, but it works, and that's what matters.

 

Thanks for your suggestions!

DS

Recommended Articles