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
Luis180189
Level I

String col edit box to data table script --> Help needed.

Hello all, 

I have created the following script that allows me to have a user interface where I can add a number or word as an input and it creates a jmp table once you click "Pull lot". 

I'd like to do something similar but instead of using the "Text Edit Box" tool that allows me to only use one input I'd like to use the "String col edit box" so I can add multiple inputs instead of one.  
My main problem is, I don't know how to take the data from the string col edit box and assign it to a table when I create the script.   Any help would be very welcome. 

Luis.  

 

User_Input = New Window( "Socket Lot Data Scripting tool",
Text Box( "Enter Lot Num:" ),
a= Text Edit Box( "Write something", <<set width( 200 )),
Button Box( "Pull Lot",<<setFunction(Function({bs}, bs=dt=New Table( "Untitled 9",Add Rows( 1 ),New Column( "Zlot", Character, "Nominal",<<Set initial data(a<<get text )));
;;))));

1 ACCEPTED SOLUTION

Accepted Solutions

Re: String col edit box to data table script --> Help needed.

The only trick is that a String Col Edit Box contains a list of values, not just a single string.

 

In this example, I changed the table part of the script to get the number of items in the String Col Edit Box and add that many rows to the table, and to use Set Values with that string. I also added a context menu to the Table Box that lets you add a row or delete the last row, in case the number of strings can vary. You could get fancier and get input to add multiple rows or delete particular rows. When you're creating the table, you could also cull the empty string from empty rows in the String Col Edit Box, if you wanted to. I didn't code that part.

 

User_Input = New Window( "Socket Lot Data Scripting tool",
	//Text Box( "Enter Lot Num:" ),
	tb = Table Box(
		a = String Col Edit Box( "Enter Lot Num:", { "Write something", "", "", "" } ),
		<< Set Context Menu Script(
			{ "Add Row", tb<<Add Row({""}),
			  "Delete Last Row", tb<<Delete Row( N Items(a<<Get) )
			}
		)
	),
	Button Box( "Pull Lot",
		<<setFunction(
			Function( {this}, {bs, strs},
				strs = a << get;
				/* could remove empty strings here before making your table */
				bs = dt = New Table( "Untitled 9",
					Add Rows( N Items(strs) ),
					New Column( "Zlot", Character, "Nominal", <<Set values( strs ) )
				);
			)
		)
	)
);

HTH,

Melanie

View solution in original post

2 REPLIES 2

Re: String col edit box to data table script --> Help needed.

The only trick is that a String Col Edit Box contains a list of values, not just a single string.

 

In this example, I changed the table part of the script to get the number of items in the String Col Edit Box and add that many rows to the table, and to use Set Values with that string. I also added a context menu to the Table Box that lets you add a row or delete the last row, in case the number of strings can vary. You could get fancier and get input to add multiple rows or delete particular rows. When you're creating the table, you could also cull the empty string from empty rows in the String Col Edit Box, if you wanted to. I didn't code that part.

 

User_Input = New Window( "Socket Lot Data Scripting tool",
	//Text Box( "Enter Lot Num:" ),
	tb = Table Box(
		a = String Col Edit Box( "Enter Lot Num:", { "Write something", "", "", "" } ),
		<< Set Context Menu Script(
			{ "Add Row", tb<<Add Row({""}),
			  "Delete Last Row", tb<<Delete Row( N Items(a<<Get) )
			}
		)
	),
	Button Box( "Pull Lot",
		<<setFunction(
			Function( {this}, {bs, strs},
				strs = a << get;
				/* could remove empty strings here before making your table */
				bs = dt = New Table( "Untitled 9",
					Add Rows( N Items(strs) ),
					New Column( "Zlot", Character, "Nominal", <<Set values( strs ) )
				);
			)
		)
	)
);

HTH,

Melanie

Luis180189
Level I

Re: String col edit box to data table script --> Help needed.

Thank you so much. 

This is great!