cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
Choose Language Hide Translation Bar
Jackie_
Level VI

Loop through list, create Tab box, Graph Builder Plot

Hi,

 

I am trying to loop through the list to create a tab box and add variables stored in the list in the graph builder. Something doesn't seem to be correct in my jsl code. Any suggestions?

 

Here is what I want - Add the columns from each list in X for each tabs

Jackie__0-1693430655836.png

 

dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

List1 = {"NPN1", "PNP1", "PNP2", "NPN2", "PNP3", "IVP1"};
List2 = {"PNP4", "NPN3", "IVP2", "NPN4", "SIT1"};
List3 = {"INM1", "INM2", "VPM1", "VPM2", "VPM3"};
List4 = {"SNM1", "SPM1", "NPN5", "EP2", "ZD6"};



var expr1 = Expr( Variables() );
For( c = 1, c <= N Items( List1 ), c++,
	x expr1 = Expr(
		X( Position( 1 ), Combine( "Parallel Merged" ) )
	);
	Insert Into( x expr1, List1[c], 1 );
	Insert Into( var expr1, Name Expr( x expr1 ) );
);


var expr2 = Expr( Variables() );
For( c = 1, c <= N Items( List2 ), c++,
	x expr2 = Expr(
		X( Position( 1 ), Combine( "Parallel Merged" ) )
	);
	Insert Into( x expr2, List2[c], 1 );
	Insert Into( var expr2, Name Expr( x expr2 ) );
);

var expr3 = Expr( Variables() );
For( c = 1, c <= N Items( List3 ), c++,
	x expr3 = Expr(
		X( Position( 1 ), Combine( "Parallel Merged" ) )
	);
	Insert Into( x expr3, List3[c], 1 );
	Insert Into( var expr3, Name Expr( x expr3 ) );
);

var expr4 = Expr( Variables() );
For( c = 1, c <= N Items( List4 ), c++,
	x expr4 = Expr(
		X( Position( 1 ), Combine( "Parallel Merged" ) )
	);
	Insert Into( x expr4, List4[c], 1 );
	Insert Into( var expr4, Name Expr( x expr4 ) );
);


lists = {"List1", "List2", "List3", "List4"};

var = {};

For( i = 1, i <= 20, i++, 
	
	Insert Into( var, Parse( "var expr" || Char( i ) ) );
	Insert Into( gbv, Parse( "vvv" || Char( i ) ) )
	
	
	;
);

New Window( "Plots",
	Show Menu( 0 ),
	show toolbars( 0 ), 

	tb = Tab Box()
);
For( i = 1, i <= N Items( lists ), i++,
	tb << Add(
		lists[i],
		V List Box(
			H List Box(
				gb1 = Eval Expr(
					
							
						
					dt << Graph Builder(
						Size( 1117, 781 ),
						Show Control Panel( 0 ),
						////something is not correct here?????
						Expr( Name Expr( var[i] ) ),
						Elements(
							Histogram(
								X( 2 ),
								X( 3 ),
								X( 4 ),
								X( 5 ),
								X( 6 ),
								X( 7 ),
								X( 8 ),
								X( 9 ),
								X( 10 ),
								X( 11 ),
								X( 12 ),
								X( 13 ),
								X( 14 ),
								X( 15 ),
								X( 16 ),
								X( 1 ),
								Legend( 2 ), 
							
							),
							Box Plot(
								X( 2 ),
								X( 3 ),
								X( 4 ),
								X( 5 ),
								X( 6 ),
								X( 7 ),
								X( 8 ),
								X( 9 ),
								X( 10 ),
								X( 11 ),
								X( 12 ),
								X( 13 ),
								X( 14 ),
								X( 15 ),
								X( 16 ),
								X( 1 ),
								Legend( 3 ),
								Outliers( 0 )
							)
						)
					)
				),
				gb1, 
				
			
			
			
				Tabulate(
					Show Control Panel( 0 ),
					Set Format( Uniform Format( 10, 2 ) ),
					Add Table(
						Column Table( Statistics( Mean, Std Dev ) ),
						Row Table(
							Analysis Columns(
								Eval( Parse( lists[i] ) )
								
							)
						)
					)

				)
		
		
		
		
		
			)
		)
	);
	
);

Thanks,

Jackie

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Loop through list, create Tab box, Graph Builder Plot

I would most likely rewrite the script to avoid using parse on variable names and having so many lists which you have to keep track of (also if you have JMP16+ using For Each is usually better than For). I did some modifications and now it might work

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

List1 = {"NPN1", "PNP1", "PNP2", "NPN2", "PNP3", "IVP1"};
List2 = {"PNP4", "NPN3", "IVP2", "NPN4", "SIT1"};
List3 = {"INM1", "INM2", "VPM1", "VPM2", "VPM3"};
List4 = {"SNM1", "SPM1", "NPN5", "EP2", "ZD6"};

var expr1 = Expr(Variables());
For(c = 1, c <= N Items(List1), c++,
	x expr1 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr1, List1[c], 1);
	Insert Into(var expr1, Name Expr(x expr1));
);

var expr2 = Expr(Variables());
For(c = 1, c <= N Items(List2), c++,
	x expr2 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr2, List2[c], 1);
	Insert Into(var expr2, Name Expr(x expr2));
);

var expr3 = Expr(Variables());
For(c = 1, c <= N Items(List3), c++,
	x expr3 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr3, List3[c], 1);
	Insert Into(var expr3, Name Expr(x expr3));
);

var expr4 = Expr(Variables());
For(c = 1, c <= N Items(List4), c++,
	x expr4 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr4, List4[c], 1);
	Insert Into(var expr4, Name Expr(x expr4));
);


lists = {"List1", "List2", "List3", "List4"};
var = {};
gbv = {};

For(i = 1, i <= 4, i++, 	
	Insert Into(var, Name Expr(Eval(Parse("var expr" || Char(i)))));
	Insert Into(gbv, Parse("vvv" || Char(i)));
);

nw = New Window("Plots",
	Show Menu(0),
	show toolbars(0), 
	tb = Tab Box()
);

For(i = 1, i <= N Items(lists), i++,
	tb << Add(
		lists[i],
		V List Box(
			H List Box(
				Eval(Eval Expr(	
					dt << Graph Builder(
						Size(1117, 781),
						Show Control Panel(0), 
						////something is not correct here?????
						Expr(Name Expr(var[i])),
						Elements(
							Histogram(
								X(2),
								X(3),
								X(4),
								X(5),
								X(6),
								X(7),
								X(8),
								X(9),
								X(10),
								X(11),
								X(12),
								X(13),
								X(14),
								X(15),
								X(16),
								X(1),
								Legend(2), 
							
							),
							Box Plot(
								X(2),
								X(3),
								X(4),
								X(5),
								X(6),
								X(7),
								X(8),
								X(9),
								X(10),
								X(11),
								X(12),
								X(13),
								X(14),
								X(15),
								X(16),
								X(1),
								Legend(3),
								Outliers(0)
							)
						)
					)
				)),
				Tabulate(
					Show Control Panel(0),
					Set Format(Uniform Format(10, 2)),
					Add Table(
						Column Table(Statistics(Mean, Std Dev)),
						Row Table(
							Analysis Columns(
								Eval(Parse(lists[i]))
								
							)
						)
					)
				)	
			)
		)
	);	
);
-Jarmo

View solution in original post

5 REPLIES 5
jthi
Super User

Re: Loop through list, create Tab box, Graph Builder Plot

Have you checked your expressions are being built correctly? First try to get it working with just one list and then add others when that is working. I can't run the script due to this error

jthi_0-1693457717301.png

Can insert only into an L-value in access or evaluation of 'Insert Into' , Insert Into/*###*/(gbv, Parse("vvv" || Char(i)))

at line 58 in \Script.jsl
-Jarmo
Jackie_
Level VI

Re: Loop through list, create Tab box, Graph Builder Plot

@jthi 

This expression works with one list but if I try to add it in the loop, it doesn't work

Eval(
					Substitute(
							Expr(
								gb2 = dt << Graph Builder(
									Size( 1117, 781 ),
									Show Control Panel( 0 ),
									vvv1,
									Elements(
										Histogram(
											X( 2 ),
											X( 3 ),
											X( 4 ),
											X( 5 ),
											X( 6 ),
											X( 7 ),
											X( 8 ),
											X( 9 ),
											X( 10 ),
											X( 11 ),
											X( 12 ),
											X( 13 ),
											X( 14 ),
											X( 15 ),
											X( 16 ),
											X( 1 ),
											Legend( 2 ), 
							
										),
										Box Plot(
											X( 2 ),
											X( 3 ),
											X( 4 ),
											X( 5 ),
											X( 6 ),
											X( 7 ),
											X( 8 ),
											X( 9 ),
											X( 10 ),
											X( 11 ),
											X( 12 ),
											X( 13 ),
											X( 14 ),
											X( 15 ),
											X( 16 ),
											X( 1 ),
											Legend( 3 ),
											Outliers( 0 )
										)
									)
								)
							),
						Expr( vvv1 ), Name Expr( var expr1 )
					)
				);
	
	
				tabu = Tabulate(
					Show Control Panel( 0 ),
					Set Format( Uniform Format( 10, 2 ) ),
					Add Table(
						Column Table( Statistics( Mean, Std Dev ) ),
						Row Table(
							Analysis Columns(
								Eval(List1)
								
							)
						)
					)

				)

 

jthi
Super User

Re: Loop through list, create Tab box, Graph Builder Plot

I would most likely rewrite the script to avoid using parse on variable names and having so many lists which you have to keep track of (also if you have JMP16+ using For Each is usually better than For). I did some modifications and now it might work

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

List1 = {"NPN1", "PNP1", "PNP2", "NPN2", "PNP3", "IVP1"};
List2 = {"PNP4", "NPN3", "IVP2", "NPN4", "SIT1"};
List3 = {"INM1", "INM2", "VPM1", "VPM2", "VPM3"};
List4 = {"SNM1", "SPM1", "NPN5", "EP2", "ZD6"};

var expr1 = Expr(Variables());
For(c = 1, c <= N Items(List1), c++,
	x expr1 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr1, List1[c], 1);
	Insert Into(var expr1, Name Expr(x expr1));
);

var expr2 = Expr(Variables());
For(c = 1, c <= N Items(List2), c++,
	x expr2 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr2, List2[c], 1);
	Insert Into(var expr2, Name Expr(x expr2));
);

var expr3 = Expr(Variables());
For(c = 1, c <= N Items(List3), c++,
	x expr3 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr3, List3[c], 1);
	Insert Into(var expr3, Name Expr(x expr3));
);

var expr4 = Expr(Variables());
For(c = 1, c <= N Items(List4), c++,
	x expr4 = Expr(
		X(Position(1), Combine("Parallel Merged"))
	);
	Insert Into(x expr4, List4[c], 1);
	Insert Into(var expr4, Name Expr(x expr4));
);


lists = {"List1", "List2", "List3", "List4"};
var = {};
gbv = {};

For(i = 1, i <= 4, i++, 	
	Insert Into(var, Name Expr(Eval(Parse("var expr" || Char(i)))));
	Insert Into(gbv, Parse("vvv" || Char(i)));
);

nw = New Window("Plots",
	Show Menu(0),
	show toolbars(0), 
	tb = Tab Box()
);

For(i = 1, i <= N Items(lists), i++,
	tb << Add(
		lists[i],
		V List Box(
			H List Box(
				Eval(Eval Expr(	
					dt << Graph Builder(
						Size(1117, 781),
						Show Control Panel(0), 
						////something is not correct here?????
						Expr(Name Expr(var[i])),
						Elements(
							Histogram(
								X(2),
								X(3),
								X(4),
								X(5),
								X(6),
								X(7),
								X(8),
								X(9),
								X(10),
								X(11),
								X(12),
								X(13),
								X(14),
								X(15),
								X(16),
								X(1),
								Legend(2), 
							
							),
							Box Plot(
								X(2),
								X(3),
								X(4),
								X(5),
								X(6),
								X(7),
								X(8),
								X(9),
								X(10),
								X(11),
								X(12),
								X(13),
								X(14),
								X(15),
								X(16),
								X(1),
								Legend(3),
								Outliers(0)
							)
						)
					)
				)),
				Tabulate(
					Show Control Panel(0),
					Set Format(Uniform Format(10, 2)),
					Add Table(
						Column Table(Statistics(Mean, Std Dev)),
						Row Table(
							Analysis Columns(
								Eval(Parse(lists[i]))
								
							)
						)
					)
				)	
			)
		)
	);	
);
-Jarmo
Jackie_
Level VI

Re: Loop through list, create Tab box, Graph Builder Plot

Thanks Jarmo!

Jackie_
Level VI

Re: Loop through list, create Tab box, Graph Builder Plot

Hi @Mark_Bailey 

I tried using the expression you suggested in the below discussion but something doesn't seem to work. Any work around for this?

Use variable list of columns as Y Axis in Graph Builder - JMP User Community