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

Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

Hi Guys,

 

I have this script that works 100% when I run it manually. 

When I run it from the toolbar(automatically) it does not run the last section.

 

Do you have an idea of why this is happening?

 

I added a comment in the script in the point is not working anymore:

//STARTING FROM HERE THE SCRIPT DOES NOT RUN IN TOOLBAR MODE

 

//Script for GRR Anlaysis for Qual Data

names = {};
//prueba={};
RepeatabilityData = {};
ReproducibilityData = {};
GaugeRRData = {};
ParttoPartData = {};
NDCData = {};

Datos_table = Current Data Table();

For( i = 1, i <= N Col(), i++, 

	Insert Into( names, Column Name( i ) )
);

dlg1 = Dialog(
	Title( "GR&R" ),
	"Select Tests",
	vlist( selectiontests = List Box( names ) ),
	"Select Channel Column",
	vlist( selectionchannel = List Box( names ) ),
	"Select Category (Pre/Post) Column",
	vlist( selectioncategory = List Box( names ) ),
	"select Devices Number Column",
	vlist( selectionSN = List Box( names ) ),
	synch = Check Box( "Generate Journal", 0 ),
	hlist( button( "OK" ), button( "Cancel" ) )
)
;

if (dlg1["Button"]==1,

	column(dlg1["selectionchannel"])<<set modeling type("Nominal");
	column(dlg1["selectioncategory"])<<set modeling type("Nominal");
	column(dlg1["selectionSN"])<<set modeling type("Nominal");	
	
	Report= New Window("GRR Report",
	
	For(i=1, i<=Nitems(dlg1["selectiontests"]),i++,
		
		uno=Variability Chart(
			Y(dlg1 ["selectiontests"][i]),
			X(dlg1 ["selectionchannel"], dlg1["selectionSN"]),
			Model (Crossed),
			Historical Sigma (0),
			Connect Cell Means (1),
			Show Group Means (1),
			Show Grand Mean (0),
			Show Grand Median (1),
			XBar Control Limits (0),
			S control Limits (1),
			Std Dev Chart (0),
			Mean Plots (0),
			Mean of Std Dev (1),
			//Gauge RR (10,2),
			//Gauge RR Report (0),
			//)
			//Journal Window;	
		
		);
		
		dos=Variability Chart(
		Y(dlg1 ["selectiontests"][i]),
		X(dlg1 ["selectioncategory"], dlg1["selectionSN"]),
		Model (Crossed),
		Historical Sigma (0),
		Variability Chart( 0 ),
		Connect Cell Means (1),
		Show Group Means (1),
		Show Grand Mean (0),
		Show Grand Median (1),
		XBar Control Limits (0),
		S control Limits (1),
		Std Dev Chart (0),
		Mean Plots (1),
		Mean of Std Dev (1),

		
		);
		
		report(uno)[framebox(1)]<<frame size(978,150);
		uno<<Show Grand Mean(1);
		uno<<XBar Control Limits(1);

		report(dos)[framebox(1)]<<frame size(186,150);	
		report(dos)[framebox(2)]<<frame size(300,150);	
		report(dos)[framebox(3)]<<frame size(300,150);	

		
	);

	
	);

//GRR Analysis Data Table


TabWin=Datos_table << Tabulate(
	Add Table(
		Column Table(
			Analysis Columns(
				(dlg1["selectiontests"])
			),
			Grouping Columns(dlg1 ["selectioncategory"] ),
			Statistics( Mean )
		),
		Row Table( Grouping Columns( :SN, Chan ) )
	)
);
	
TabData = TabWin<< Make Into Data Table;
TabWin << Close Window;
TabData <<set name("GRR Analysis");

//*
//Section for Deltas in GRR analysis
CurrentDataTable(TabData);

ColNum=NCols();

For (j=3, j<=ColNum, j=j+2,
	
	ColLen=Length(Char(Column name (j)));
	ColName=Left (Char(Column Name(j)),ColLen -5);
	NewCol=Substr(ColName,6);
	
TabData<<New Column(
		"Delta: "||NewCol,
		Numeric,
		Formula(
			(As Column((j))-As Column((j+1)))/As Column(j)
		),
		Format("Percent",5,2)	
	)
);

ColDelta=(ColNum-2)/2;
ColStart=4;

ListDelta = {};

For(k=1, k<=ColDelta, k++,
	
	Insert Into(ListDelta, Column Name (Eval(ColNum+k)));
	TabData << Move Selected Columns(
		{Column (ColNum+k)}, after(Column(ColStart))
	);
	ColStart=ColStart+3;
	
	
);
//STARTING FROM HERE THE SCRIPT DOES NOT RUN IN TOOLBAR MODE
//Delta Variability
	DeltaVar= New Window("GRR Delta Report",
	
		For(l=1, l<=Nitems(ListDelta),l++,
			
			//Col Std Dev(As Column(ListDelta[12]));
			
			if(Col Std Dev(As Column(ListDelta[l]))>0.4,
				ListDelta[l]<<set property ("Spec Limits",{LSL(-1 ), USL(1),Show Limits( 1 )})
			);
			
			if(Col Std Dev(As Column(ListDelta[l]))<0.4,
				ListDelta[l]<<set property ("Spec Limits",{LSL(-0.1 ), USL( 0.1),Show Limits( 1 )})
			);
			if(Col Std Dev(As Column(ListDelta[l]))<0.001,
				ListDelta[l]<<set property ("Spec Limits",{LSL(-0.01 ), USL( 0.01),Show Limits( 1 )})
			);
		
			tres=Variability Chart(
				Y(ListDelta[l]),
				X(:Chan, :SN),
				Model (Crossed),
				Historical Sigma (0),
				Connect Cell Means (1),
				Show Group Means (1),
				Show Grand Mean (0),
				Show Grand Median (1),
				XBar Control Limits (1),
				S control Limits (1),
				Std Dev Chart (0),
				Mean Plots (0),
				Mean of Std Dev (1),
				//Gauge RR (10,2),
				//Gauge RR Report (0),
			);
			
			//report(tres)[FrameBox(1)]<<frame size(978,150);
			//tres<<Show Grand Mean(1);
			//tres<<XBar Control Limits(1);

		);

	);
	
);
	
	
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

@CrownofTears -- way too late, I suppose, but try adding

TabData << RunFormulas;

in place of the comment. JMP's column formulas run when JMP is idle, so running it a section at a time will allow the formulas to evaluate. Adding wait statements might let the formulas have enough idle time to complete, but it is impossible to pick the perfect wait time. <<RunFormulas is fast. Usually JMP can figure out when it needs to force the formulas to finish running; My guess is that

Col Std Dev(As Column(ListDelta[l]))

is not figuring it out.

Craige

View solution in original post

4 REPLIES 4
ron_horne
Super User (Alumni)

Re: Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

Hi @CrownofTears ,

when i had these issues in the past i found out that adding Wait (0.1) before the loop and at the end of each loop made it work. in your case i a do not have an obvious suspect for the slow behaviour. i would just put a Wait (0.1) after each ; in the last loop and see if it works  
this solves the issue that sometimes jmp moves on the the next step without making sure the previous has ended.

Craige_Hales
Super User

Re: Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

@CrownofTears -- way too late, I suppose, but try adding

TabData << RunFormulas;

in place of the comment. JMP's column formulas run when JMP is idle, so running it a section at a time will allow the formulas to evaluate. Adding wait statements might let the formulas have enough idle time to complete, but it is impossible to pick the perfect wait time. <<RunFormulas is fast. Usually JMP can figure out when it needs to force the formulas to finish running; My guess is that

Col Std Dev(As Column(ListDelta[l]))

is not figuring it out.

Craige
CrownofTears
Level II

Re: Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

Hi @Craige_Hales, we shoud exactly add the 

TabData << RunFormulas;

After this comment?

//STARTING FROM HERE THE SCRIPT DOES NOT RUN IN TOOLBAR MODE

if yes, already did and did not work

Craige_Hales
Super User

Re: Do you know why my script fully runs when I run it manually but it does not work when I run it from a command in the toolbar?

(Yes, that was what I meant.)

I'm guessing.

Are you getting messages in the log window when it fails? You might add print() statements to isolate the failure.

 

My next guess is the current data table() isn't doing what you expect. Try using explicit data table scoping instead of depending on CurrentDataTable.

Depending on the CurrentDataTable is a fragile way to build code because

  • it can change when another table becomes current (which seems likely with a new window opening)
  • it can be different in different contexts (which seems likely with a toolbar context in play)

Another thing to try: uncheck the "use here namespace" in the toolbar to see if it works. That will tell us something too.

Craige