cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
SpannerHead
Level III

Recall Button

I posted this question on the original thread but it was probably not highlighted properly, so trying as a fresh post.

 

The code at this link looks very useful

 

How to create a Recall button on a custom window - JMP User Community

 

However, it's not obvious to me how to capitalise on the recall function properly.

 

I have some code (below) I borrowed and modified that lacks recall and I was trying to figure out how to weld them together.  I'm close but missing something as usual.  All help appreciated.

 

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 )
						)
					)
				)
			)
		);
	)
);

 

Thanks

 

Slán

 

SpannerHead

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Recall Button

Slán,

 Below is a simple combining of your script with the script referenced in How to create a Recall button on a custom window. To start with, your provided example uses a Column Dialog() and the Recall Example uses a New Window for the user dialog.  JMP had depreciated the Column Dialog in favor of New Window.  What you need to do is to study the script and learn how it works.  It brings in several items that will take some understanding.   NameSpaces being a major one.

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;

// The program to execute when the OK button is pressed
pgm = Expr(
	nw = New Window( "Annotated Multiple Plots",
		For( i = 1, i <= N Items( exy ), i++,
			Notes = Try( 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 )
							)
						)
					)
				)
			);
		)
	)
);

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

/* Expression to store the current settings in global variables */ 
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << 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", colListY << Append( colListData << GetSelected ) ),
						colListY = Col List Box( width( lbWidth ), nmin( 1 ), nLines( 5 ), numeric ),
						Button Box( "X", colListX << Append( colListData << GetSelected ) ),
						colListX = Col List Box( width( lbWidth ), nLines( 1 ), numeric )
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							
							exy = colListY << get items;
							exx = colListX << get items;
							pgm;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							/* Restore any previous settings from the namespace variables */
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
							);
						)
					)
				)
			)
		)
	)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

Please note that I removed several line of code in your supplied JSL that did not seem to do anything for the example.

Jim

View solution in original post

jthi
Super User

Re: Recall Button

You can take inspiration from the script Jim provided and then apply Recall Function Library to that. That is most likely pretty great way of learning many different things for JSL (modify existing working solution to use different package). I don't personally like the way that recall library works so I haven't used it (I have my own in the making) but to my knowledge, it is currently the best way to implement recall without writing everything yourself.

-Jarmo

View solution in original post

5 REPLIES 5
txnelson
Super User

Re: Recall Button

Slán,

 Below is a simple combining of your script with the script referenced in How to create a Recall button on a custom window. To start with, your provided example uses a Column Dialog() and the Recall Example uses a New Window for the user dialog.  JMP had depreciated the Column Dialog in favor of New Window.  What you need to do is to study the script and learn how it works.  It brings in several items that will take some understanding.   NameSpaces being a major one.

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;

// The program to execute when the OK button is pressed
pgm = Expr(
	nw = New Window( "Annotated Multiple Plots",
		For( i = 1, i <= N Items( exy ), i++,
			Notes = Try( 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 )
							)
						)
					)
				)
			);
		)
	)
);

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

/* Expression to store the current settings in global variables */ 
recallRoles = Expr(
	dialogRecallNS:ycolRecall = colListY << GetItems;
	dialogRecallNS:orderRecall = colListX << 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", colListY << Append( colListData << GetSelected ) ),
						colListY = Col List Box( width( lbWidth ), nmin( 1 ), nLines( 5 ), numeric ),
						Button Box( "X", colListX << Append( colListData << GetSelected ) ),
						colListX = Col List Box( width( lbWidth ), nLines( 1 ), numeric )
					)
				),
				Panel Box( "Action",
					Lineup Box( N Col( 1 ),
						Button Box( "OK",
							recallRoles;
							
							exy = colListY << get items;
							exx = colListX << get items;
							pgm;
							customDlg << CloseWindow;
						),
						Button Box( "Cancel", customDlg << CloseWindow ),
						Button Box( "Reset", clearRoles ),
						Text Box( " " ),
						Button Box( "Remove",
							colListY << RemoveSelected;
							colListX << RemoveSelected;
						),
						Button Box( "Recall",
							clearRoles;
							/* Restore any previous settings from the namespace variables */
							Try(
								colListY << Append( dialogRecallNS:ycolRecall );
								colListX << Append( dialogRecallNS:orderRecall );
							);
						)
					)
				)
			)
		)
	)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

Please note that I removed several line of code in your supplied JSL that did not seem to do anything for the example.

Jim
SpannerHead
Level III

Re: Recall Button

This is really close and it works as described, however, the whole purpose was to have a way to force the graphs to have annotation based on the information in the notes and somehow that breaks in this revision.

 

Annotations turn up missing and the Notes themselves don't contain anything.

 

			Notes = Try(exy[i] << Get Property( "Notes" ));
			Show(Notes);

Any clue why that might be?

 

Thanks

 

Slán

 

SpannerHead

 

jthi
Super User

Re: Recall Button

Try changing

Notes = Try(exy[i] << Get Property("Notes"));

to

Notes = Try(Column(dt, exy[i]) << Get Property("Notes"));

as << Get items for Col List Box returns list of strings

-Jarmo
jthi
Super User

Re: Recall Button

You can take inspiration from the script Jim provided and then apply Recall Function Library to that. That is most likely pretty great way of learning many different things for JSL (modify existing working solution to use different package). I don't personally like the way that recall library works so I haven't used it (I have my own in the making) but to my knowledge, it is currently the best way to implement recall without writing everything yourself.

-Jarmo
SpannerHead
Level III

Re: Recall Button

That's spot on, combining those works.

 

Thanks

 

Slán

 

SpannerHead