It’s World Statistics Day! To honor the theme of the day, the JMP User Community is having conversations about the importance of trust in statistics and data. And we want to hear from you! Tell us the steps you take to ensure that your data is trustworthy.
Choose Language Hide Translation Bar
Highlighted
Yngeinstn
Level IV

Append an Open Window after a selection is made

I have been searching for a solution to be able to append an open window after a selection is made from from a calendar box.

 

Once the Start Date and End Date are selected I would like to open another box right below the panel box that holds the calendar(s)

 

Below is an example i am trying in the simplfied version. In my actual application I would like to open a check box() list based on the dates selected from a database that was based on an sql script..

 

Thank You

 

 


nw = New Window( "Example", V List Box( pb = Panel Box( "Calendar", V List Box( H List Box( Panel Box( "Select Start", StartDate = Calendar Box( << Set Function( Function( {f1}, sqlstartA = StartDate << Get Date(); ) ) ) ), // End StartDate Calendar Box Panel Box( "Select End", EndDate = Calendar Box( << Set Function( Function( {f2}, sqlendA = EndDate << Get Date(); ) ) ) ) // End EndDate Calendar Box ), H List Box( bb1 = Button Box( "Set Dates", sqlstart = format(sqlstartA, "yyyy-mm-dd"); sqlend = format(sqlendA, "yyyy-mm-dd"); show(sqlstart, sqlend); ), bb2 = Button Box( "Cancel" ) ), Wait( 0.1 ), pb << Append( Text Box( "Why isn't this working" ) ) ) ) ) );

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: Append an Open Window after a selection is made

Working in a hurry, I'm not sure what I did to your original. But the code below does indeed work. Generally I find it helps readability and maintainability to define actions as expressions with a name, then invoke them using that name.

nw = New Window( "Example",
	V List Box(
		pb = Panel Box( "Calendar",
			V List Box(
				H List Box(
					Panel Box( "Select Start",
						StartDate = Calendar Box(
							<<Set Function( Function( {f1}, sqlstartA = StartDate << Get Date() ) )
						)
					), // End StartDate Calendar Box
					Panel Box( "Select End",
						EndDate = Calendar Box(
							<<Set Function( Function( {f2}, sqlendA = EndDate << Get Date() ) )
						)
					) // End EndDate Calendar Box	
				),
				H List Box(
					bb1 = Button Box( "Set Dates", pb << Append(Text Box( "Why isn't this working" ))),
					bb2 = Button Box( "Cancel" )
				)
			)
		)
	)
);

View solution in original post

5 REPLIES 5
Highlighted
ian_jmp
Staff

Re: Append an Open Window after a selection is made

Working in a hurry, I'm not sure what I did to your original. But the code below does indeed work. Generally I find it helps readability and maintainability to define actions as expressions with a name, then invoke them using that name.

nw = New Window( "Example",
	V List Box(
		pb = Panel Box( "Calendar",
			V List Box(
				H List Box(
					Panel Box( "Select Start",
						StartDate = Calendar Box(
							<<Set Function( Function( {f1}, sqlstartA = StartDate << Get Date() ) )
						)
					), // End StartDate Calendar Box
					Panel Box( "Select End",
						EndDate = Calendar Box(
							<<Set Function( Function( {f2}, sqlendA = EndDate << Get Date() ) )
						)
					) // End EndDate Calendar Box	
				),
				H List Box(
					bb1 = Button Box( "Set Dates", pb << Append(Text Box( "Why isn't this working" ))),
					bb2 = Button Box( "Cancel" )
				)
			)
		)
	)
);

View solution in original post

Highlighted
Yngeinstn
Level IV

Re: Append an Open Window after a selection is made

That is crazy because it wasn't working... Thank you for pointing that out
Highlighted
Yngeinstn
Level IV

Re: Append an Open Window after a selection is made

Allow me to expand on that if I may.

Now that you got that to work with a text box the actual solution i am trying to solve is placing a check box that gets populated when you push Set Dates. I tried to insert LotListBox = Check Box( LotList, doListChoice ); in place of the Text Box() and i am only getting the panel window..

 

From what i can gather the the last 4 sets of script isn't executing therefore just sending an empty window.

 

/* -----------------------------------------------------------*/
/* Calendar Box to Select Start and End Dates				  */
/* -----------------------------------------------------------*/

nw = New Window( "Example",
	V List Box(
		pb = Panel Box( "Calendar",
			V List Box(
				H List Box(
					Panel Box( "Select Start",
						StartDate = Calendar Box(
							<<Set Function( 
								Function( 
									{f1}, 
									sqlstartA = StartDate << Get Date() 
								) 
							)
						)
					), // End StartDate Calendar Box
					Panel Box( "Select End",
						EndDate = Calendar Box(
							<<Set Function( 
								Function( 
									{f2}, sqlendA = EndDate << Get Date() 
								) 
							)
						)
					),
					dtLotList;// End EndDate Calendar Box	
				),
				H List Box(
					bb1 = Button Box( "Set Dates",
						pb << Append(
							Panel Box( " ",
								V List Box(
									Text Box( "Select Wafer(s)" )
								),
								LotListBox = Check Box( LotList, doListChoice ) // Pulls from the Database basedd on the dates selected above
							)
						)
					),
					bb2 = Button Box( "Cancel" )
				)
			)
		)
	)
);
			
// SQL Code that brings in the entire wafer list from database		
SQLcode = Expr(
		"
	SELECT DISTINCT 
		t1.wafer_number,
		t1.testdate
	FROM tst_master  t1
		LEFT OUTER JOIN tst_dataset_header t2 
			ON  ( t2.run_id = t1.run_id )
	WHERE t1.testdate >= ' " || sqlstart || " '
		AND t1.testdate <= ' " || sqlend || " '
		AND (t1.wafer_number NOT RLIKE '-ATL' )
		ORDER BY t1.testdate DESC
	"
);

/*****************************************************************************/
/*                                                                           */
/* Brings in the list of wafers from the SQL Query	 		                 */
/*                                                                           */
/*****************************************************************************/

/**************************************************************/
/* Opens Database based on Calendar Dates and Lists Lots	  */
/**************************************************************/
// Tried to put this in an expression to execute in the main window
dtLotList = Expr(
	
dt_LotList = Open Database(  <Database String>, SQLcode, "LotList" );

Summarize( LotList = By( :wafer_number ) );

Close( dt_lotlist, No Save );

);
// Original script to bring in a list of wafers within the date range
dt_LotList = Open Database( <Database String>, SQLcode, "LotList" );

Summarize( LotList = By( :wafer_number ) );

Close( dt_lotlist, No Save );


/**************************************************************/
/* Lists Lot List in Check Box Format						  */
/**************************************************************/
// This is what i would like to be appended in the first window
LotListBox = Check Box( LotList, doListChoice );

/**************************************************************/
/* Allows for Multiple Lots to be Selected					  */
/**************************************************************/

doListChoice = Expr(

	SelectedLot = LotListBox << get selected; //get the selected items
	
	If( N Items( SelectedLot ) > 0, //run through each selected item if there are any
	
		For( i = 1, i <= N Items( SelectedLot ), i++,
			Print( SelectedLot[i] )
		)
	);
	
	LotListSQLString = "";

	For( i = 1, i <= N Items( SelectedLot ), i++,
		LotListSQLString = LotListSQLString || "'" || Char( SelectedLot[i] );
		
		If( i == N Items( SelectedLot ),
			LotListSQLString = LotListSQLString || "'",
			LotListSQLString = LotListSQLString || "',"
		);
	);
		
	Show( SelectedLot );
);

 

Highlighted
ian_jmp
Staff

Re: Append an Open Window after a selection is made

Of course I don't have your DB. But, making corresponding simplifications to your code, this shows the mechanics of adding the check box to the UI.

/* -----------------------------------------------------------*/
/* Calendar Box to Select Start and End Dates				  */
/* -----------------------------------------------------------*/

nw = New Window( "Example",
	V List Box(
		pb = Panel Box( "Calendar",
			V List Box(
				H List Box(
					Panel Box( "Select Start", StartDate = Calendar Box( <<Set Function( Function( {f1}, sqlstartA = StartDate << Get Date() ) ) ) ), 	// End StartDate Calendar Box
					Panel Box( "Select End", EndDate = Calendar Box( <<Set Function( Function( {f2}, sqlendA = EndDate << Get Date() ) ) ) ) 			// End EndDate Calendar Box	
				),
				H List Box(
					bb1 = Button Box( "Set Dates", pb << Append( Panel Box( "Select Wafer(s)", LotListBox = Check Box( LotList, Beep() ) ) ) ),
					bb2 = Button Box( "Cancel" )
				)
			)
		)
	)
);
			
LotList = {"A", "B", "C"};

 

Highlighted
Yngeinstn
Level IV

Re: Append an Open Window after a selection is made

Thank you very much.. I was trying a Wait() in between that part of the
code.. When i was reading the forums i saw something about Pause before
executing a script and saw the beep() however i didn't even think about
putting that in there..

Thanks you very much again..
Article Labels

    There are no labels assigned to this post.