cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
How to create a Recall button on a custom window

Overview

When using the JMP® Scripting Language (JSL) to generate a custom window to prompt the user for information, it is often desirable to add a button that restores settings from a previous launch of the window within the same JMP instance. Similar functionality is available when launching a platform interactively, such as by clicking the Analyze menu and selecting Distribution.

Currently, there is no built-in JSL method for creating a Recall button as you see in the Distribution platform launch and Tables menu dialogs. However, you can create your own implementation.

The following example generates a custom window where the user can cast columns from the active data table into appropriate roles. When the OK button is clicked, the user's settings are stored in variables defined in a named namespace. On subsequent launches of the window, the Recall button clears any current settings and restores the values from the namespace.

Instructions

In a JMP session, click the File menu and select New ► Script. Copy the below script and paste it into the script window. To run the sample script, click the Edit menu and select Run Script.

Names Default to Here(1);

/* Assign dt to reference a table.  Open a sample table for demonstration purposes */
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

/* Use a named namespace to hold the recall values */
if(!Namespace Exists("Custom Dialog"), // define namespace if it does not exist
	dialogRecallNS = New Namespace("Custom Dialog",
	{
		ycolRecall = {},
		orderRecall = {},
		byRecall = {}
	});
, // else get a reference to the existing namespace
	dialogRecallNS = NameSpace("Custom Dialog");
);

nc = N Col( dt );
lbWidth = 130;

/* Expression to clear all current settings */ 
clearRoles = Expr(
	colListY << RemoveAll;
	colListX << RemoveAll;
	colListB << RemoveAll;
);

/* Expression to store the current settings in global variables */ 
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << GetItems;
	dialogRecallNS:byRecall = colListB << GetItems;
);

/* Custom Launch Window */ 
customDlg = New Window( "Example of a Custom Dialog",
	Border Box( Left( 3 ), top( 2 ),
		V List Box(
			Text Box( "Example dialog to demonstrate a Recall button" ),
			H List Box(
				V List Box(
					Panel Box( "Select Columns",
						colListData = Col List Box( All, width( lbWidth ), nLines( Min( nc, 10 ) ) )
					)
				),
				Panel Box( "Cast Selected Columns into Roles",
					Lineup Box( N Col( 2 ), Spacing( 3 ),
						Button Box( "Y, Response", colListY << Append( colListData << GetSelected ) ),
						colListY = Col List Box( width( lbWidth ), nLines( 5 ), numeric ),
						Button Box( "X, Factor", colListX << Append( colListData << GetSelected ) ),
						colListX = Col List Box( width( lbWidth ), nLines( 1 ), numeric ),
						Button Box( "By", colListB << Append( colListData << GetSelected ) ),
						colListB = Col List Box( width( lbWidth ), nLines( 1 ) )
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
							colListB << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							/* Restore any previous settings from the namespace variables */
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
								colListB << Append( dialogRecallNS:byRecall );
							);
						)
					)
				)
			)
		)
	)
);

Additional Documentation

More information about the JMP Scripting Language can be found in the JMP Scripting Guide. You can access the guide from within JMP by clicking on the Help menu and select JMP Help.  From the online Table of Contents, choose Scripting Guide.

 

[Previously JMP Note 46984]

Comments
hogi

alternative approach (including some other display boxes):
via the Recall Function Library  by @MikeD_Anderson 

Very helpful thanks.

I looked at the script and it looks like what I need, however, I'm not able to figure out how to add the resulting plot script to take advantage of it.  My original script looks like this but lacks a recall button.  Not sure where to append my script?  Also, do I need to make this script modal?

 

 

Slán

 

SpannerHead

dt = Current Data Table();
cd = Column Dialog(
	exy = ColList( "Y", Min Col( 1 ) ),
	exx = ColList( "X", Min Col( 1 ) )
);
Eval( cd[1] );
Eval( cd[2] );
yyy = Expr( y() );
xxx = Expr( x() );
xval = exx[1];
For( i = 1, i <= N Items( exy ), i++,
	Insert Into( yyy, exy[i] )
);
For( i = 1, i <= N Items( exx ), i++,
	Insert Into( xxx, exx[i] )
);
nw = New Window( "Annotated Multiple Plots",
	For( i = 1, i <= N Items( exy ), i++,
		Notes = exy[i] << Get Property( "Notes" );
		Try(
			Bivariate(
				Y( exy[i] ),
				X( exx[1] ),
				SendToReport(
					Dispatch(
						{},
						"",
						AxisBox( 2 ),
						Add Text Annotation(
							Text( "Category: " || Notes ),
							Fixed Size( 0 ),
							Text Box( {-80, 25, 0, 50} ),
							Filled( 0 )
						)
					)
				)
			)
		);
	)
);
Details
Operating System
macOS Windows
Products JMP JMP Pro