Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
cnattrass
Level II

Input Validation in a button box

Im trying to validate user input and prevent them from passing the Input UI if they do not enter required fields. So far it seems like the button box doesnt actually run the script in sequence, or it doesnt seem to store the variables until the entire script is finished. How can I get around this? 

 

clearLog();
clearGlobals();
clearSymbols();

dt = currentDataTable();

inputGUI = newWindow( "Input Selection UI", << modal,

//Step Name input box
	hListBox(
		textBox("1. Enter some text input"),
		stepTextEdit = textEditBox(),
	),
//Column Section input box
	hListBox(
		vListBox(
			choosesrc=filterColSelector( nLines( 6 ) ),
			chooseSRC << numeric( 0 ),
		),
		vListBox(
			lineUpBox( nCol( 1 ), spacing( 2 ),
			
				buttonBox( "Add Column >>",
					listcols2 << Append( chooseSRC << getSelected );
				),
				buttonBox( "<< Remove Column",
					listcols2 << removeSelected;
				),
			),
		),
		vListBox(
			listcols2 = colListBox( nLines( 3 ), minItems(1), maxItems(1) ), //col list box with no columns inside
		);
	),
//Footer Section and OK/Cancel Buttons
	hListBox(
		buttonBox("OK", 
			//Collect all variables from input boxes
			uinp_stepName = stepTextEdit << getText;
			uinp_colssrc=listcols2 << getItems;
			// Input Validation Logic
			if ( IsMissing(uinp_stepName) == 1, 
				(nw_error_uinp_stepName = New Window("Error ", << Modal,
					   VList Box(
							  Text Box("Text input is missing"),
							  HList Box(
									 Button Box ( "OK" ),
							  ),
					   );
					);
					break(); // Only send 1 error at a time
				)
			);
			if ( nItems(uinp_colsSRC) == 0, 
				(nw_error_uinp_colssrc=New Window("Error ", << Modal,
					   VList Box(
									 Spacer Box( Size (5, 5) ),
							  Text Box("Column input is missing"),
									 Spacer Box( Size (15, 15) ),
							  HList Box(
									 Button Box ( "OK" ),
								),
							);
						);
					break(); // Only send 1 error at a time
				)
			);
		),
		buttonBox("Cancel", Print("User cancelled operation!"); Stop() ),
	),
);
2 REPLIES 2
Highlighted
cwillden
Super User

Re: Input Validation in a button box

I don't think it's evaluating anything out of sequence. The problem is you are trying to modify that filterColSelector object in a line separated by a comma.  The comma is meant to separate different display objects that are nested within that vertical list box.  Swap that code snippet with this one and you should be good:

vListBox(
	choosesrc=filterColSelector( nLines( 6 ), << numeric( 0 ))
)

 *Also, I'm not sure if you plan to append anything else to that vListBox, but since it only contains 1 display box, you can probably get rid of it.

-- Cameron Willden
Highlighted

Re: Input Validation in a button box

Also, see the in-line message << On Validate( expression ) to New Window() for this purpose.

Learn it once, use it forever!
Article Labels

    There are no labels assigned to this post.