cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
SDF1
Super User

Toggle button box or something similar

Hi JMP Community,

 

  I'm trying to set up a window where users can select different months, or quarters, or the entire YTD, that also provides feedback of which button boxes have been selected (or even deselected). My intent is to ultimately use the month/quarter/YTD selection as a way to create a subset of a data table based on the month (year is always set to current year for now).

 

  Here's a window of what I'm thinking about:

SDF1_2-1730819595588.png

 

 

  Whenever a month is selected, the code will define a variable as "01" for Jan, "05" for May, or "1" for Q1, etc. What I'd like is for the button to look like it's either "clicked" by appearing pressed, or better turn a highlighted color, like blue. Something similar to what happens in the Data Filter platform, like when using Big Class and adding a local Data Filter by :name, where the name is highlighted and more than one selection can be made at a time. Along with showing that the button has been selected, I would like it to show if the button has been deselected -- much like a check box showing it's marked or not -- but I don't want to use check boxes as it's less visually appealing.

SDF1_1-1730819129226.png

 

  The code for the window I created looks like (see below), and of course, when the user clicks on "OK", the code will then create the subset data table and then also close the selection window. In setting the variable for the month selected "mo#", is there a less cumbersome way to assign it the 01Jan2024 value than the code AsDate(Date DMY(dd,mm,yyyy))? it works just fine, it's just a bit cumbersome.

 

Names Default To Here( 1 );

yr = Year( Today() );

subwin = New Window( "Select Subset",
	<<Type( "Dialog" ), <<Size(360,200),
	Panel Box( "Select Month(s) in Current Year for Subset",
		LB = Lineup Box( N Col( 5 ),
			Button Box( "Jan", mo1 = AsDate(Date DMY(01,01,eval(yr))) ),
			Button Box( "Feb", mo2 =  AsDate(Date DMY(01,02,eval(yr)))),
			Button Box( "March", mo3 = AsDate(Date DMY(01,03,eval(yr))) ),
			Spacer Box(),
			Button Box( "Q1", q = 1 ),
			Button Box( "April", mo4 = AsDate(Date DMY(01,04,eval(yr))) ),
			Button Box( "May", mo5 = AsDate(Date DMY(01,05,eval(yr))) ),
			Button Box( "June", mo6 = AsDate(Date DMY(01,06,eval(yr))) ),
			Spacer Box(),
			Button Box( "Q2", q = 2 ),
			Button Box( "July", mo7 = AsDate(Date DMY(01,07,eval(yr))) ),
			Button Box( "Aug", mo8 = AsDate(Date DMY(01,08,eval(yr))) ),
			Button Box( "Sep", mo9 = AsDate(Date DMY(01,09,eval(yr))) ),
			Spacer Box(),
			Button Box( "Q3", q = 3 ),
			Button Box( "Oct", m10 = AsDate(Date DMY(01,10,eval(yr))) ),
			Button Box( "Nov", m11 = AsDate(Date DMY(01,11,eval(yr))) ),
			Button Box( "Dec", m12 = AsDate(Date DMY(01,12,eval(yr))) ),
			Spacer Box(),
			Button Box( "Q4", q = 4 ),
			Button Box( "YTD", y = 12 ),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Button Box("OK"),
			Button Box("Cancel/Exit", subwin << Close Window)
		)
	)
);

  Any help is much appreciated!

 

Thanks!,

DS

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Toggle button box or something similar

Button Box supports Toggle style

Names Default To Here(1);
New Window("Toggle Button Example",
	ex = Button Box("Start",
		If(ex << Get,
			ex << Set Button Name("Stop"),
			ex << Set Button Name("Start")
		)
	)
);
ex << Style("Toggle");

jthi_0-1730822990356.pngjthi_1-1730822996996.png

 

-Jarmo

View solution in original post

SDF1
Super User

Re: Toggle button box or something similar

Hi @jthi and @txnelson ,

 

  Thank you both for the valuable feedback. All your suggestions gave me some ideas on what to work on and how to modify the existing code to get what I needed. I liked @txnelson 's idea of the start date and end date, but unfortunately, it doesn't allow non-continuous selection of months and or quarters. For example, a user might select Jan and Sep as months or Q1 and Q4 as quarters to then grab the subset from. So, I had to rewrite that to allow for non-continuous dates. I even threw in a check if the user was selecting months and quarters or YTD and any mix so they'd have to go back and select just one group or another.

 

  My solution to this was actually to use Associative Arrays, and I was pleased with the outcome as well as utilizing AA's since I haven't really worked much with them. The code I came up with is below. I know it's not very elegant or compact, but it works and gets the job done, which is sometimes all that's needed, right?!

 

  Thanks for all the help and quick feedback. I love being able to pose a problem on this forum and then less than 24hrs later have a functioning script that solves all the concerns I needed. Below is the code I ended up writing:

Names Default To Here( 1 );

dt = Current Data Table();

yr = Year( Today() );

MonthAA = Associative Array( {"M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} );
QAA = Associative Array( {"Q1", "Q2", "Q3", "Q4"}, {1, 2, 3, 4} );
YTDAA = Associative Array( {"YTD"}, {12} );

MonthList = {};
QList = {};
QMonths = {};
YTDList = {};

ClearExpr = Expr(
	dt << Clear Select;
	MonthList = {};
	QList = {};
	QMonths = {};
	YTDList = {};
	BB1 << Set( 0 );
	BB2 << Set( 0 );
	BB3 << Set( 0 );
	BB4 << Set( 0 );
	BB5 << Set( 0 );
	BB6 << Set( 0 );
	BB7 << Set( 0 );
	BB8 << Set( 0 );
	BB9 << Set( 0 );
	BB10 << Set( 0 );
	BB11 << Set( 0 );
	BB12 << Set( 0 );
	BB13 << Set( 0 );
	BB14 << Set( 0 );
	BB15 << Set( 0 );
	BB16 << Set( 0 );
	BB17 << Set( 0 );
);

OKExpr = Expr(
	dt << Clear Select;
	MonthList = {};
	QList = {};
	QMonths = {};
	YTDList = {};
	For( i = 1, i <= 17, i++,
		tempBB = Eval( Parse( "BB" || Char( i ) ) ) << Get;
		If( tempBB == 1,
			If(
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "M", Insert Into( MonthList, Eval( Parse( "Sel" || Char( i ) ) ) ),
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Q", Insert Into( QList, Eval( Parse( "Sel" || Char( i ) ) ) ),
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Y", Insert Into( YTDList, Eval( Parse( "Sel" || Char( i ) ) ) )
			)
		);
	);
	If(
		N Items( MonthList ) != 0 & N Items( QList ) != 0 | N Items( MonthList ) != 0 & N Items( YTDList ) != 0 | N Items( QList ) != 0 &
		N Items( YTDList ) != 0,
		ErrorWin = New Window( "Error Window",
			<<Type( "Dialog" ),
			V List Box(
				Spacer Box(),
				Text Box( "Invalid selection. Please 'Clear' and select month(s), quarter(s), OR YTD.", <<Set Font Size( 16 ) ),
				H List Box( Spacer Box(), Button Box( "OK", ErrorWin << Close Window ), Spacer Box() )
			)
		);
		Error = 1;
	,
		Error = 0
	);
	If( N Items( MonthList ) != 0 & Error == 0,
		MonthNum = MonthAA << Get Values( MonthList );
		For( m = 1, m <= N Items( MonthList ), m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, MonthNum[m], yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
	If( N Items( QList ) != 0 & Error == 0,
		QNum = QAA << Get Values( QList );
		For( q = 1, q <= N Items( QNum ), q++,
			If(
				QNum[q] == 1, Insert Into( QMonths, {"M1", "M2", "M3"} ),
				QNum[q] == 2, Insert Into( QMonths, {"M4", "M5", "M6"} ),
				QNum[q] == 3, Insert Into( QMonths, {"M7", "M8", "M9"} ),
				QNum[q] == 4, Insert Into( QMonths, {"M10", "M11", "M12"} )
			)
		);
		MonthNum = MonthAA << Get Values( QMonths );
		For( m = 1, m <= N Items( QMonths ), m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, MonthNum[m], yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
	If( N Items( YTDList ) != 0 & Error == 0,
		YTDNum = YTDAA << Get Values( YTDList );
		For( m = 1, m <= YTDNum[1], m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, m, yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
);

subwin = New Window( "Select Subset",
	<<Type( "Dialog" ),
	<<Size( 380, 200 ),
	Panel Box( "Select Month(s) OR quarter(s) OR YTD in Current Year for Subset",
		LB = Lineup Box( N Col( 5 ),
			BB1 = Button Box( "Jan", Sel1 = "M1", <<Style( "Toggle" ) ),
			BB2 = Button Box( "Feb", Sel2 = "M2", <<Style( "Toggle" ) ),
			BB3 = Button Box( "March", Sel3 = "M3", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB4 = Button Box( "Q1", Sel4 = "Q1", <<Style( "Toggle" ) ),
			BB5 = Button Box( "April", Sel5 = "M4", <<Style( "Toggle" ) ),
			BB6 = Button Box( "May", Sel6 = "M5", <<Style( "Toggle" ) ),
			BB7 = Button Box( "June", Sel7 = "M6", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB8 = Button Box( "Q2", Sel8 = "Q2", <<Style( "Toggle" ) ),
			BB9 = Button Box( "July", Sel9 = "M7", <<Style( "Toggle" ) ),
			BB10 = Button Box( "Aug", Sel10 = "M8", <<Style( "Toggle" ) ),
			BB11 = Button Box( "Sep", Sel11 = "M9", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB12 = Button Box( "Q3", Sel12 = "Q3", <<Style( "Toggle" ) ),
			BB13 = Button Box( "Oct", Sel13 = "M10", <<Style( "Toggle" ) ),
			BB14 = Button Box( "Nov", Sel14 = "M11", <<Style( "Toggle" ) ),
			BB15 = Button Box( "Dec", Sel15 = "M12", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB16 = Button Box( "Q4", Sel16 = "Q4", <<Style( "Toggle" ) ),
			BB17 = Button Box( "YTD", Sel17 = "YTD", <<Style( "Toggle" ) ),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Button Box( "Clear", ClearExpr ),
			Button Box( "OK", OKExpr ),
			Button Box( "Cancel/Exit", subwin << Close Window )
		)
	)
);

Thanks!,

DS

 

View solution in original post

7 REPLIES 7

Re: Toggle button box or something similar

You might use radio buttons for this purpose. You could use one set to define whether the period is months or quarters. You could have another dynamic set to offer either the twelve months or the four quarters. Both options could be created when the window is opened, but one set (not the default) could be invisible. The first set of radio buttons would manage the visibility of the second set as well as the logic.

Re: Toggle button box or something similar

You can also group radio boxes so that only one will be active at any given time:

Names Default To Here( 1 );
r1 = Radio Box( {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"} );
r2 = Radio Box( {"Q1", "Q2", "Q3", "Q4"} );
New Window( "Example", H List Box( r1, r2 ) );
r2 << Group( r1 );
jthi
Super User

Re: Toggle button box or something similar

Button Box supports Toggle style

Names Default To Here(1);
New Window("Toggle Button Example",
	ex = Button Box("Start",
		If(ex << Get,
			ex << Set Button Name("Stop"),
			ex << Set Button Name("Start")
		)
	)
);
ex << Style("Toggle");

jthi_0-1730822990356.pngjthi_1-1730822996996.png

 

-Jarmo
SDF1
Super User

Re: Toggle button box or something similar

Hi @jthi ,

 

  This definitely solved the toggle problem I was after. Now, the only challenge is how to set up the logic structure when someone clicks "OK" so that it will select only those mm/yyyy rows in the data table for all possible combinations of months selected or quarters, etc. Trying to think of a way that this doesn't get really big really fast. Any ideas?

 

Thanks!,

DS

jthi
Super User

Re: Toggle button box or something similar

I'm not sure how your data looks like or how you do wish to perform the selections but I would separate the UI and logic. I made modifications to your UI but it isn't necessary, this just makes it a bit easier to collect the buttons. This will just demonstrate how you can build the dates from months, it won't do it for YTD or Quarters as I'm not sure how you will be using those

Names Default To Here(1);

get_dates = Expr(
	months = Loc(m_buttons << get, 1);
	qs = Loc(q_buttons << get, 1);
	ys = Loc(y_buttons << get, 1);

	// loop over as necessary to create the combinations
	dates_to_find = Transform Each({month}, months,
		Date DMY(01, month, yr);
	);
);

yr = Year(Today());

subwin = New Window("Select Subset",
	<<Type("Dialog"),
	<<Size(360, 200),
	Panel Box("Select Month(s) in Current Year for Subset",
			V List Box(align("right"),
				H List Box(
					V List Box(
						lub_m = Lineup Box(N Col(3),
							Button Box("Jan"),
							Button Box("Feb"),
							Button Box("March"),
							Button Box("April"),
							Button Box("May"),
							Button Box("June"),
							Button Box("July"),
							Button Box("Aug"),
							Button Box("Sep"),
							Button Box("Oct"),
							Button Box("Nov"),
							Button Box("Dec")
						),
						lub_y = Lineup Box(N Col(1),
							btn_ytd = Button Box("YTD")							
						)
					),
				Spacer Box(Size(50,0)),
				lub_q = Lineup Box(N Col(1),
					Button Box("Q1"),
					Button Box("Q2"),
					Button Box("Q3"),
					Button Box("Q4")				
				),
			),
			Lineup Box(N Col(2),
				Button Box("OK",
					get_dates;
					show(dates_to_find);
				),
				Button Box("Cancel/Exit", subwin << Close Window)
			)
		)
	)
);

btns = subwin << XPath("//ButtonBox");
Remove From(btns, N Items(btns)-2, 2);
btns << Style("Toggle");

// selections = Loc(btns << get, 1);
// btns[selections] << Get Button Name;

m_buttons = lub_m << XPath("//ButtonBox");
q_buttons = lub_q << XPath("//ButtonBox");
y_buttons = lub_y << XPath("//ButtonBox");
-Jarmo
SDF1
Super User

Re: Toggle button box or something similar

Hi @jthi and @txnelson ,

 

  Thank you both for the valuable feedback. All your suggestions gave me some ideas on what to work on and how to modify the existing code to get what I needed. I liked @txnelson 's idea of the start date and end date, but unfortunately, it doesn't allow non-continuous selection of months and or quarters. For example, a user might select Jan and Sep as months or Q1 and Q4 as quarters to then grab the subset from. So, I had to rewrite that to allow for non-continuous dates. I even threw in a check if the user was selecting months and quarters or YTD and any mix so they'd have to go back and select just one group or another.

 

  My solution to this was actually to use Associative Arrays, and I was pleased with the outcome as well as utilizing AA's since I haven't really worked much with them. The code I came up with is below. I know it's not very elegant or compact, but it works and gets the job done, which is sometimes all that's needed, right?!

 

  Thanks for all the help and quick feedback. I love being able to pose a problem on this forum and then less than 24hrs later have a functioning script that solves all the concerns I needed. Below is the code I ended up writing:

Names Default To Here( 1 );

dt = Current Data Table();

yr = Year( Today() );

MonthAA = Associative Array( {"M1", "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "M10", "M11", "M12"}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} );
QAA = Associative Array( {"Q1", "Q2", "Q3", "Q4"}, {1, 2, 3, 4} );
YTDAA = Associative Array( {"YTD"}, {12} );

MonthList = {};
QList = {};
QMonths = {};
YTDList = {};

ClearExpr = Expr(
	dt << Clear Select;
	MonthList = {};
	QList = {};
	QMonths = {};
	YTDList = {};
	BB1 << Set( 0 );
	BB2 << Set( 0 );
	BB3 << Set( 0 );
	BB4 << Set( 0 );
	BB5 << Set( 0 );
	BB6 << Set( 0 );
	BB7 << Set( 0 );
	BB8 << Set( 0 );
	BB9 << Set( 0 );
	BB10 << Set( 0 );
	BB11 << Set( 0 );
	BB12 << Set( 0 );
	BB13 << Set( 0 );
	BB14 << Set( 0 );
	BB15 << Set( 0 );
	BB16 << Set( 0 );
	BB17 << Set( 0 );
);

OKExpr = Expr(
	dt << Clear Select;
	MonthList = {};
	QList = {};
	QMonths = {};
	YTDList = {};
	For( i = 1, i <= 17, i++,
		tempBB = Eval( Parse( "BB" || Char( i ) ) ) << Get;
		If( tempBB == 1,
			If(
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "M", Insert Into( MonthList, Eval( Parse( "Sel" || Char( i ) ) ) ),
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Q", Insert Into( QList, Eval( Parse( "Sel" || Char( i ) ) ) ),
				Substr( Eval( Parse( "Sel" || Char( i ) ) ), 1, 1 ) == "Y", Insert Into( YTDList, Eval( Parse( "Sel" || Char( i ) ) ) )
			)
		);
	);
	If(
		N Items( MonthList ) != 0 & N Items( QList ) != 0 | N Items( MonthList ) != 0 & N Items( YTDList ) != 0 | N Items( QList ) != 0 &
		N Items( YTDList ) != 0,
		ErrorWin = New Window( "Error Window",
			<<Type( "Dialog" ),
			V List Box(
				Spacer Box(),
				Text Box( "Invalid selection. Please 'Clear' and select month(s), quarter(s), OR YTD.", <<Set Font Size( 16 ) ),
				H List Box( Spacer Box(), Button Box( "OK", ErrorWin << Close Window ), Spacer Box() )
			)
		);
		Error = 1;
	,
		Error = 0
	);
	If( N Items( MonthList ) != 0 & Error == 0,
		MonthNum = MonthAA << Get Values( MonthList );
		For( m = 1, m <= N Items( MonthList ), m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, MonthNum[m], yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
	If( N Items( QList ) != 0 & Error == 0,
		QNum = QAA << Get Values( QList );
		For( q = 1, q <= N Items( QNum ), q++,
			If(
				QNum[q] == 1, Insert Into( QMonths, {"M1", "M2", "M3"} ),
				QNum[q] == 2, Insert Into( QMonths, {"M4", "M5", "M6"} ),
				QNum[q] == 3, Insert Into( QMonths, {"M7", "M8", "M9"} ),
				QNum[q] == 4, Insert Into( QMonths, {"M10", "M11", "M12"} )
			)
		);
		MonthNum = MonthAA << Get Values( QMonths );
		For( m = 1, m <= N Items( QMonths ), m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, MonthNum[m], yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
	If( N Items( YTDList ) != 0 & Error == 0,
		YTDNum = YTDAA << Get Values( YTDList );
		For( m = 1, m <= YTDNum[1], m++,
			dt << Select Where( :"Month Year[Date]"n == As Date( Date DMY( 1, m, yr ) ), Current Selection( "extend" ) )
		);
		dtSubset = dt << Subset( Selected Columns( 0 ), Selected Rows( 1 ), Suppress formula evaluation( 0 ) );
	);
);

subwin = New Window( "Select Subset",
	<<Type( "Dialog" ),
	<<Size( 380, 200 ),
	Panel Box( "Select Month(s) OR quarter(s) OR YTD in Current Year for Subset",
		LB = Lineup Box( N Col( 5 ),
			BB1 = Button Box( "Jan", Sel1 = "M1", <<Style( "Toggle" ) ),
			BB2 = Button Box( "Feb", Sel2 = "M2", <<Style( "Toggle" ) ),
			BB3 = Button Box( "March", Sel3 = "M3", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB4 = Button Box( "Q1", Sel4 = "Q1", <<Style( "Toggle" ) ),
			BB5 = Button Box( "April", Sel5 = "M4", <<Style( "Toggle" ) ),
			BB6 = Button Box( "May", Sel6 = "M5", <<Style( "Toggle" ) ),
			BB7 = Button Box( "June", Sel7 = "M6", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB8 = Button Box( "Q2", Sel8 = "Q2", <<Style( "Toggle" ) ),
			BB9 = Button Box( "July", Sel9 = "M7", <<Style( "Toggle" ) ),
			BB10 = Button Box( "Aug", Sel10 = "M8", <<Style( "Toggle" ) ),
			BB11 = Button Box( "Sep", Sel11 = "M9", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB12 = Button Box( "Q3", Sel12 = "Q3", <<Style( "Toggle" ) ),
			BB13 = Button Box( "Oct", Sel13 = "M10", <<Style( "Toggle" ) ),
			BB14 = Button Box( "Nov", Sel14 = "M11", <<Style( "Toggle" ) ),
			BB15 = Button Box( "Dec", Sel15 = "M12", <<Style( "Toggle" ) ),
			Spacer Box(),
			BB16 = Button Box( "Q4", Sel16 = "Q4", <<Style( "Toggle" ) ),
			BB17 = Button Box( "YTD", Sel17 = "YTD", <<Style( "Toggle" ) ),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Button Box( "Clear", ClearExpr ),
			Button Box( "OK", OKExpr ),
			Button Box( "Cancel/Exit", subwin << Close Window )
		)
	)
);

Thanks!,

DS

 

txnelson
Super User

Re: Toggle button box or something similar

Here is a rework of your JSL.....it really isn't tested, however it should be close enough for you to use it to complete your request

Names Default To Here( 1 );

dt=current data table();

theYear = Year( Today() );

resetbb = Expr(
	For( i = 1, i <= 17, i++,
		Eval( Parse( "bb" || Char( i ) || "<< enable(1);" ) )
	)
);

subwin = New Window( "Select Subset",
	<<Type( "Dialog" ),
	<<Size( 360, 200 ),
	Panel Box( "Select Month(s) in Current Year for Subset",
		LB = Lineup Box( N Col( 5 ),
			bb1 = Button Box( "Jan",
				Sel = "M1";
				resetbb;
				bb1 << enable( 0 );
			),
			bb2 = Button Box( "Feb",
				Sel = "M2";
				resetbb;
				bb2 << enable( 0 );
			),
			bb3 = Button Box( "March",
				Sel = "M3";
				resetbb;
				bb3 << enable( 0 );
			),
			Spacer Box(),
			bb4 = Button Box( "Q1",
				Sel = "Q1";
				resetbb;
				bb4 << enable( 0 );
			),
			bb5 = Button Box( "April",
				Sel = "M4";
				resetbb;
				bb5 << enable( 0 );
			),
			bb6 = Button Box( "May",
				Sel = "M5";
				resetbb;
				bb6 << enable( 0 );
			),
			bb7 = Button Box( "June",
				Sel = "M6";
				resetbb;
				bb7 << enable( 0 );
			),
			Spacer Box(),
			bb8 = Button Box( "Q2",
				Sel = "Q2";
				resetbb;
				bb8 << enable( 0 );
			),
			bb9 = Button Box( "July",
				Sel = "M7";
				resetbb;
				bb9 << enable( 0 );
			),
			bb10 = Button Box( "Aug",
				Sel = "M8";
				resetbb;
				bb10 << enable( 0 );
			),
			bb11 = Button Box( "Sep",
				Sel = "M9";
				resetbb;
				bb11 << enable( 0 );
			),
			Spacer Box(),
			bb12 = Button Box( "Q3",
				Sel = "Q3";
				resetbb;
				bb12 << enable( 0 );
			),
			bb13 = Button Box( "Oct",
				Sel = "M10";
				resetbb;
				bb13 << enable( 0 );
			),
			bb14 = Button Box( "Nov",
				Sel = "M11";
				resetbb;
				bb14 << enable( 0 );
			),
			bb15 = Button Box( "Dec",
				Sel = "M12";
				resetbb;
				bb15 << enable( 0 );
			),
			Spacer Box(),
			bb16 = Button Box( "Q4",
				Sel = "Q4";
				resetbb;
				bb16 << enable( 0 );
			),
			bb17 = Button Box( "YTD",
				Sel = "YTD";
				resetbb;
				bb17 << enable( 0 );
			)
		),
		H List Box(
			Spacer Box(),
			Spacer Box(),
			Spacer Box(),
			Spacer Box(), 
			
			Button Box( "OK",
				If(
					Substr( Sel, 1, 1 ) == "M",
						theMonth = Num( Substr( Sel, 2 ) );
						startDate = Date MDY( theMonth, 1, theYear );
						If( theMonth == 12,
							endDate = Date MDY( 1, 1, theYear + 1 ),
							endDate = Date MDY( theMonth + 1, 1, theYear )
						);,
					Substr( Sel, 1, 1 ) == "Q",
						theMonth = Num(
							Substr( Sel, 2 );
							If(
								theMonth == 2,
									startDate = Date MDY( 4, 1, theYear );
									endDate = Date MDY( 7, 1, theYear );,
								theMonth == 3,
									startDate = Date MDY( 7, 1, theYear );
									endDate = Date MDY( 10, 1, theYear );,
								theMonth == 4,
									startDate = Date MDY( 10, 1, theYear );
									endDate = Date MDY( 1, 1, theYear + 1 );,
								startDate = Date MDY( 1, 1, theYear );
								endDate = Date MDY( 4, 1, theYear );,
							);,
							startDate = Date MDY( 1, 1, theYear );
							endDate = Today() + In Days( 1 );
						)
				);
				dt << select where( startDate >= :Date < endDate );
				dtSubset = dt << subset( selected columns( 0 ), selected rows( 1 ) );
				subwin << Close Window;
			),
			Button Box( "Cancel/Exit", subwin << Close Window )
		)
	)
);
Jim