For the latest version of JMP Help, visit JMP.com/help.

Scripting Guide > Display Trees > Construct Custom Windows > Extract Values from a Window
Publication date: 09/28/2021

Extract Values from a Window

After the user selects options in a window, you can extract those selections from the window using the Return Result message, Get message, or Get Selected message.

Extract Values: Method One

To have a New Window() script automatically return the results after the user clicks OK, include the Return Result message after the Modal message.

win = New Window( "Set a Value",
	<<Modal,
	<<Return Result,
	Text Box( "Set this value" ),
	variablebox = Number Edit Box( 42 ),
	Button Box( "OK" ),
	Button Box( "Cancel" )
);
Write( win["variablebox"] ); // create a subscript to the variablebox variable

33 // the user typed "33" in the number edit box

Extract Values: Method Two

Include the Get message to return 1 for a selected check box and 0 for a deselected check box. To view the selection, add a Show() expression at the end of the script.

win = New Window( "V List Box",
	<<Modal,
	V List Box(
		kb1 = Check Box( "a" ),
		kb2 = Check Box( "b" ),
		kb3 = Check Box( "c" )
	),
	Button Box( "OK",
		val1 = kb1 << Get; // get the value of the first check box
		val2 = kb2 << Get;
		val3 = kb3 << Get;
	)
);
Show( val1, val2, val3 ); // return variables after window closes

val1 = 1; // first and second checkboxes are selected

val2 = 1;

val3 = 0; // third checkbox is not selected

Extract Values: Method Three

Include the Get Selected message to return the selected column names and then insert the columns in a Bivariate plot.

Note: Method two and method three of extracting values are alternate examples of the same method. The method, in both examples, uses a JSL callback from one of the controls in the window. The JSL callback captures a value from a display box in the window into a global variable that will be available after the window closes. In method two, the JSL callback is on a button box. In method three, the JSL callback is on a list box.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
xvar = .;
yvar = .;
win = New Window( "Return Values",
	<<Modal,

// require the user to select two variables before clicking OK

	<<On Validate(
		Show( xvar, yvar );
	 		If( Is Missing( xvar ) | Is Missing( yvar ),
				0, // if xvar or yvar are missing, do nothing when OK is clicked
			1
		);
	),
	Text Box( " Select two numeric columns. " ),
	H List Box(
		Text Box( " X, Factor " ),
		x = Col List Box(
			dt, // data table reference
			all, // display all columns from the data table
			xvar = (x << Get Selected)[1];

// get the name of the selected column before the window closes

			Show( xvar );
		),
		Text Box( "Y, Response" ),
		y = Col List Box(
			dt,
			all,
			yvar = (y << Get Selected)[1];
			Show( yvar );
		)
	)
);
xcol = Column( dt, xvar ); // get the columns
ycol = Column( dt, yvar );
 
dt << Bivariate( Y( ycol ), X( xcol ) ); // create a Bivariate plot
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).