cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
andylin127
Level I

How to pull data from a combo box that has a text edit box and number edit box?

Hi All,

 

Im currently trying to create a script that will create columns in a data table based on user inputs. It will first ask the user for the column name, then parse the names in the columns into different characters depending on user inputs. I'm having trouble with the get evaluation if there are less than 7 options picked in the combo box. Im currently getting the error that the deleted boxes are cannot be evaluated of 'Glue'. is there a way around this? I've tried the try function and it gave me some weird values.

 

Thanks,

Andy

 

clearlog();

dt = Current Data Table();
nc = ncol(dt);

New Window("SID parser",
	H List Box("Main Box",
		V List Box("VLISTBOXcolumn names",
			PanelBox("Select Column",
				colListData=ColListBox(All,nLines(min(nc,10)))
			), //end panel box
		), // end VLISTBOXcolumn names
		V List Box("VLISTBOXDIGITS",
			Text Box("Select Number of Columns"),
			x = Combo Box( {"1", "2","3","4","5","6","7"},
				<< set function( Function( {this},
				value = this << get;
				If(
					value == 1,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( 
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
							) // end 1st column HLISTBOX
						)	
					), 
					
					value == 2,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							) // end 2nd column h list box
						) //end VLISTBOX
					), // end sib append
					
					value == 3,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							), // end 2nd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y3 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z3 = Text Edit Box("Tube Type"),
								z3 << set width(100),
							), // end 3rd column h list box
						) //end VLISTBOX
					), // end sib append
					
					value == 4,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							), // end 2nd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y3 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z3 = Text Edit Box("Tube Type"),
								z3 << set width(100),
							), // end 3rd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y4 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z4 = Text Edit Box("Sample Number"),
								z4 << set width(100),
							), // end 4th column h list box
						), //end VLISTBOX
					), // end sib append
					
					value == 5,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							), // end 2nd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y3 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z3 = Text Edit Box("Tube Type"),
								z3 << set width(100),
							), // end 3rd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y4 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z4 = Text Edit Box("Sample Number"),
								z4 << set width(100),
							), // end 4th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y5 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z5 = Text Edit Box("Analyte Level"),
								z5 << set width(100),
							), // end 5th column h list box
						), //end VLISTBOX
					), // end sib append
					
					value == 6,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							), // end 2nd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y3 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z3 = Text Edit Box("Tube Type"),
								z3 << set width(100),
							), // end 3rd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y4 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z4 = Text Edit Box("Sample Number"),
								z4 << set width(100),
							), // end 4th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y5 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z5 = Text Edit Box("Analyte Level"),
								z5 << set width(100),
							), // end 5th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y6 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z6 = Text Edit Box("Run"),
								z6 << set width(100),
							), // end 6th column h list box
						), //end VLISTBOX
					), // end sib append
					
					value == 7,
					Try( (this << sib) << deletebox ); // delete what might already exist
					this << sibappend( // add new box
						V List Box( 
							H List Box(
								Text Box("Number of Characters"),
								y = Number Edit Box(2,4),
								Text Box("Column Name"),
								z = Text Edit Box("Protocol"),
								z << set width(100),
								), // end 1st column HLISTBOX
							H List Box(
								Text Box("Number of Characters"),
								y2 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z2 = Text Edit Box("Optional"),
								z2 << set width(100),
							), // end 2nd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y3 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z3 = Text Edit Box("Tube Type"),
								z3 << set width(100),
							), // end 3rd column h list box
							H List Box(
								Text Box("Number of Characters"),
								y4 = Number Edit Box(3,4),
								Text Box("Column Name"),
								z4 = Text Edit Box("Sample Number"),
								z4 << set width(100),
							), // end 4th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y5 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z5 = Text Edit Box("Analyte Level"),
								z5 << set width(100),
							), // end 5th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y6 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z6 = Text Edit Box("Run"),
								z6 << set width(100),
							), // end 6th column h list box
							H List Box(
								Text Box("Number of Characters"),
								y7 = Number Edit Box(1,4),
								Text Box("Column Name"),
								z7 = Text Edit Box("extra"),
								z7 << set width(100),
							), // end 7th column h list box
						), //end VLISTBOX
					); // end sib append
					
				); // end if statement
			)) //end function

    ), //end combo box
		V List Box( 
			H List Box(
				Text Box("Number of Characters"),
				y = Number Edit Box(2,4),
				Text Box("Column Name"),
				z = Text Edit Box("Protocol"),
				z << set width(100),
			) // end 1st column HLISTBOX
		); // since 1 is selected by default, put the box here initially
	), //end VLISTBOXDIGITS
	), // end HLISTBOX Main Box
	H List Box("OK and Cancel",
		Button Box("OK",
			Print( "Pressed OK");
			SelectedColumn = colListData << getSelected;
			
			firstdigit = y << get();
			seconddigit = y2  << get();
			thirddigit = y3  << get();
			fourthdigit = y4  << get();
			fifthdigit = y5  << get();
			sixthdigit = y6  << get();
			seventhdigit = y7  << get();
			
			
			firstColumnName = z  << getText();
			secondColumnName =  z2  << getText();
			thirdColumnName =  z3  << getText();
			fourthColumnName = z4  << getText();
			fifthColumnName =  z5  << getText();
			sixthColumnName = z6  << getText();
			seventhColumnName = z7  << getText();
						
			currentwindow() << closewindow()
			
		), // end Button Box OK
		Button Box("Cancel", currentwindow() << closewindow())
	), // end Button Box Cancel
); //end SID parser dialog box

try( dt << Delete Column( ascolumn(firstColumnName)) );
dt << new column(firstColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),0,firstdigit),empty())
);

try( dt << Delete Column( ascolumn(secondColumnName)) );
dt << new column(secondColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,1),seconddigit),empty())
);

try( dt << Delete Column( ascolumn(thirdColumnName)) );
dt << new column(thirdColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,1),thirddigit),empty())
);

try( dt << Delete Column( ascolumn(fourthColumnName)) );
dt << new column(fourthColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,1),fourthdigit),empty())
);

try( dt << Delete Column( ascolumn(fifthColumnName)) );
dt << new column(fifthColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,1),fifthdigit),empty())
);

try( dt << Delete Column( ascolumn(sixthColumnName)) );
dt << new column(sixthColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,fifthdigit,1),sixthdigit),empty())
);

try( dt << Delete Column( ascolumn(seventhColumnName)) );
dt << new column(seventhColumnName, character, nominal,
	Formula(substr(ascolumn(SelectedColumn),Add(firstdigit,seconddigit,thirddigit,fourthdigit,fifthdigit,sixthdigit,1),seventhdigit),empty())

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: How to pull data from a combo box that has a text edit box and number edit box?

The second poblem with your script is that your dialog window is not Modal, which means the JSL after the New Window does not wait for the OK.

 

I have attached 2 scripts, that are alternatives, showing different methods to make your display dynamic.  These scripts use Big Class that has a new column named Test. Select that column (Test) . This window allows the user to change their mind, if they accidentally hit 5 but meant 6, try selecting different values.  All 7 HListBoxes are on the window but only the numebr selected are visible and names and values are retreived (<<get) with the OK script.

 

These scipts  might not meet your exact needs but should give you some ideas about alternatives to copy/paste (aka brute force) code.

 

DialogDialogResultsResults

 

View solution in original post

3 REPLIES 3
gzmorgan0
Super User (Alumni)

Re: How to pull data from a combo box that has a text edit box and number edit box?

Your application still is not clear to me. However, your script is  throwing errors, because the actions associated with the OK ButtonBox assumes all 7 number edit and text edit boxes exist. However only the boxes you created exist.

I suggest you create all 7 sets of boxes, get all seven sets of results but only use the number specified.

 

 

			firstdigit = y << get();
			seconddigit = y2  << get();
			thirddigit = y3  << get();
			fourthdigit = y4  << get();
			fifthdigit = y5  << get();
			sixthdigit = y6  << get();
			seventhdigit = y7  << get();
			
			
			firstColumnName = z  << getText();
			secondColumnName =  z2  << getText();
			thirdColumnName =  z3  << getText();
			fourthColumnName = z4  << getText();
			fifthColumnName =  z5  << getText();
			sixthColumnName = z6  << getText();
			seventhColumnName = z7  << getText();

I'll post an alternative later.

gzmorgan0
Super User (Alumni)

Re: How to pull data from a combo box that has a text edit box and number edit box?

The second poblem with your script is that your dialog window is not Modal, which means the JSL after the New Window does not wait for the OK.

 

I have attached 2 scripts, that are alternatives, showing different methods to make your display dynamic.  These scripts use Big Class that has a new column named Test. Select that column (Test) . This window allows the user to change their mind, if they accidentally hit 5 but meant 6, try selecting different values.  All 7 HListBoxes are on the window but only the numebr selected are visible and names and values are retreived (<<get) with the OK script.

 

These scipts  might not meet your exact needs but should give you some ideas about alternatives to copy/paste (aka brute force) code.

 

DialogDialogResultsResults

 

andylin127
Level I

Re: How to pull data from a combo box that has a text edit box and number edit box?

Thanks this helps so much!