Subscribe Bookmark RSS Feed

how to use combo box to pass a variable for prediction interval calculation; two-sided, one side ca

swu2

Occasional Contributor

Joined:

Jan 27, 2017

hello all,

 

i have a dialog box with a combo box " two, lower and upper", and each of them is passed to the distrubtion plaform for predition interval. however, I can pass my variable collected using the dialog box. if i manule added the "two", or "lower" or "upper" to the script, the script works, please help.

Names Default To Here( 1 );

dt= current data table();

 

//dialog box for analysis selection

dlg=New Window( "Begin Analysis", << Modal,

H List Box(

Panel Box( "Analysis",

 

 

//Column role selection

V List Box(

pb1#=H List Box(

cols = Col List Box( All ),

Line Up Box( N Col( 2 ),

Button Box( "QC, Column for Trending",

a col << Append( cols << Get Selected ),

<< Set Tip( "Pick a column for the trending chart " )

),

a col = Col List Box( N Lines( 1 ) ),

Button Box( "Trending Variables, assay date",

b col << Append( cols << Get Selected )

),

b col = Col List Box( N Lines( 1 ) ),

Button Box( "Trending Variables, run number",

c col << Append( cols << Get Selected )

),

c col = Col List Box( N Lines( 1 ) ),

 

Button Box( "Remove",

{ a col, b col, c col } << Remove Selected

)),

v list Box( e col=number edit box(0.997),

Text box("enter control range t-stat interval"),

 

v list Box ( intervals= Combo Box({"Two", "Lower","Upper"},

selection = intervals << GetSelected();),

Text box("Select two-sided, Lower one-sided, or Upper one-sided")

),

),

 

),

 

 

H List Box(

ok# = Button Box( "OK",

 

 

a col = column((a col << get items)[1]); //"QC, Column for Trending"

b col = Column( (b col << Get Items)[1] ); //"Trending Variables, assay date"

c col = Column( (c col << Get Items)[1] ); //"Trending Variables, run number"

e col =e col <<get;//t-stat interval

Selection = Selection<<Get;//select two sided or one sided

 

),

Button Box( "Cancel", << Set Tip( "Abort analysis now" ) ),

)

))));

if(Selection ==1, int = as name("two"));

if(Selection ==2, int = as name("lower"));

if(Selection ==3, int = as name("upper"));

 

nw= New Window("QC Trending Analysis",

ob = outlinebox("QC Trending" ,

utline box("Distribution",

Distribution(

Stack( 1 ),

Continuous Distribution(

Column( a col ),

Horizontal Layout( 1 ),

Vertical( 0 ),

Fit Distribution( Normal( Goodness of Fit( 1 ) ) ),

Prediction Interval( e col, 1, int),

)

)

)

)

);

2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Here is a modification of your script with changes that I believe correct the issue you are concerned with

Names Default To Here( 1 );
dt = Current Data Table();

// Default if the selection button is not ever touched
Selection = 1;

//dialog box for analysis selection
dlg = New Window( "Begin Analysis",
	<<Modal,
	H List Box(
		Panel Box( "Analysis", 
 
 
//Column role selection
			V List Box(
				pb1# = H List Box(
					cols = Col List Box( All ),
					Lineup Box( N Col( 2 ),
						Button Box( "QC, Column for Trending",
							a col << Append( cols << Get Selected),
							<<Set Tip( "Pick a column for the trending chart " )
						),
						a col = Col List Box( N Lines( 1 ) ),
						Button Box( "Trending Variables, assay date",
							b col << Append( cols << Get Selected )
						),
						b col = Col List Box( N Lines( 1 ) ),
						Button Box( "Trending Variables, run number",
							c col << Append( cols << Get Selected )
						),
						c col = Col List Box( N Lines( 1 ) ), 
 
						Button Box( "Remove", {a col, b col, c col} << Remove Selected )
					),
					V List Box(
						e col = Number Edit Box( 0.997 ),
						Text Box( "enter control range t-stat interval" ), 
 
						V List Box(
							intervals = Combo Box(
								{"Two", "Lower", "Upper"},
								// Get returns the index, Get Selected returns the value
								selection = try(intervals << Get(),1);
							),
							Text Box( "Select two-sided, Lower one-sided, or Upper one-sided" )
						),

					), 
 
				), 
 
 
				H List Box(
					ok# = Button Box( "OK", 
 
						// The using of the Try() function many times cures problems
						a col = try(Column( (a col << get items)[1] )); //"QC, Column for Trending"
						b col = Try(Column( (b col << Get Items)[1] )); //"Trending Variables, assay date"
						c col = try(Column( (c col << Get Items)[1] )); //"Trending Variables, run number"
						e col = try(e col << get);//t-stat interval
						// This code is redundent because it has already been set, and
						// Selection << Get is improper since Intervals is the object 
						//Selection = Selection << Get;//select two sided or one sided
 
					),
					Button Box( "Cancel", <<Set Tip( "Abort analysis now" ) ),

				)
			)
		)
	)
);

// This is a better form of the IF() function
If( Selection == 1,
	int = As Name( "two" ),
Selection == 2,
	int = As Name( "lower" ),
Selection == 3,
	int = As Name( "upper" )
);
 
nw = New Window( "QC Trending Analysis",
	ob = Outline Box( "QC Trending",
		Outline box(
			"Distribution",
			Distribution(
				Stack( 1 ),
				Continuous Distribution(
					Column( a col ),
					Horizontal Layout( 1 ),
					Vertical( 0 ),
					Fit Distribution( Normal( Goodness of Fit( 1 ) ) ),
					Prediction Interval( e col, 1, int ),

				)
			)
		)
	)
);
Jim
swu2

Occasional Contributor

Joined:

Jan 27, 2017

no, it dosn't solve the issue. I just make an expression to handle each case, rather than passing the character variable.

 

but, thanks for the suggestion.