Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
WendyLou315
Level III

Check Box question with subgroups with select all of each subgroup fails

Hello Folks!  I have generated a user window to select any from 2 series of charts.  The series are "Only curves" or "Curves and data points".  My issue is that I also need to have a "Select all Curves" and "Select all Curves and Points" options.  The two "Select All" check boxes work great. However, if I select anything on the Curve chart side and DO NOT select the "Select all Curves and Points" check box (even to select and deselect), rather I select one or more individually, the selected Curve and Data Point charts are not entered into the list of charts to produce.  What am I doing wrong?  Code included.  Thank you all in advance for looking at my issue!

//Generate charts for selected data
GetCharts = {};
GetDPCharts = {};

//Window for user to select which charts to be generated
WhatCharts = New Window( "Select Curve Charts to Generate", << Modal,
	<< On open( WhatCharts << Window Size( 200, 100 ) ),
	H List Box( 
	//All charts wtih ONLY curves
	cbAllCharts = Check Box( {"By Condition", "By Cond No", "By Sample", "Average by Condition"} ),
	Spacer Box( Size( 10, 0 ) ),
	//Charts with Data Points AND Curves
	cbAllDPCharts = Check Box( {"By Condition w/ Data Points", "By Cond No w/ Data Points", "By Sample w/ Data Points", "Average by Condition w/ Data Points"})
	),
	//Allow the user to select all charts
	H List Box(
	cbAll = Check Box( " ",
		<< Set Function(
			Function( {this},
				cbAllCharts << Set All( this << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select All Curve Plots" ),
	Spacer Box( Size( 9, 0 ) ),
	cbAll2 = Check Box( " ",
		<< Set Function(
			Function( {this},
				cbAllDPCharts << Set All( this << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select all Points and Curve Plots" ),
	),
	H Center Box( Button Box( "OK", GetChkBoxes ) 
	)
);

//Place all selections into one list
if( N Items( GetDPCharts ) > 0,
	For( i = 1, i<= N Items( GetDPCharts ), i++,
		Insert Into( GetCharts, GetDPCharts[i] )
	)
);

//Expressions
GetChkBoxes = Expr(
	GetCharts = cbAllCharts << Get Selected;
	GetDPCharts = cbAllDPCharts << Get Selected;
);

Print( GetCharts, GetDPCharts );
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
david707
Level III

Re: Check Box question with subgroups with select all of each subgroup fails

Give each checkbox it's own function and make sure all functions have different names:

//Generate charts for selected databutton

GetCharts = {};
GetDPCharts = {};

//Window for user to select which charts to be generated
WhatCharts = New Window( "Select Curve Charts to Generate", << Modal, << Return Result,
	//<< On open( WhatCharts << Window Size( 200, 100 ) ),
	H List Box( 
	//All charts wtih ONLY curves
	cbAllCharts = Check Box( {"By Condition", "By Cond No", "By Sample", "Average by Condition"},
		<<SetFunction( Function( {f1}, GetCharts = cbAllCharts << get selected ) ) ),
	Spacer Box( Size( 10, 0 ) ),
	//Charts with Data Points AND Curves
	cbAllDPCharts = Check Box( {"By Condition w/ Data Points", "By Cond No w/ Data Points", "By Sample w/ Data Points", "Average by Condition w/ Data Points"},
		<<SetFunction( Function( {f2}, GetDPCharts = cbAllDPCharts << get selected ) ) ),
	),
	//Allow the user to select all charts
	H List Box(
	cbAll = Check Box( " ",
		<< Set Function(
			Function( {f3},
				cbAllCharts << Set All( f3 << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select All Curve Plots" ),
	Spacer Box( Size( 9, 0 ) ),
	cbAll2 = Check Box( " ",
		<< Set Function(
			Function( {f4},
				cbAllDPCharts << Set All( f4 << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select all Points and Curve Plots" ),
	),
	H List Box( Button Box( "OK" ) )
);

//Place all selections into one list
if( N Items( GetDPCharts ) > 0,
	For( i = 1, i<= N Items( GetDPCharts ), i++,
		Insert Into( GetCharts, GetDPCharts[i] )
	)
);

Print( GetCharts, GetDPCharts );

View solution in original post

2 REPLIES 2
Highlighted
david707
Level III

Re: Check Box question with subgroups with select all of each subgroup fails

Give each checkbox it's own function and make sure all functions have different names:

//Generate charts for selected databutton

GetCharts = {};
GetDPCharts = {};

//Window for user to select which charts to be generated
WhatCharts = New Window( "Select Curve Charts to Generate", << Modal, << Return Result,
	//<< On open( WhatCharts << Window Size( 200, 100 ) ),
	H List Box( 
	//All charts wtih ONLY curves
	cbAllCharts = Check Box( {"By Condition", "By Cond No", "By Sample", "Average by Condition"},
		<<SetFunction( Function( {f1}, GetCharts = cbAllCharts << get selected ) ) ),
	Spacer Box( Size( 10, 0 ) ),
	//Charts with Data Points AND Curves
	cbAllDPCharts = Check Box( {"By Condition w/ Data Points", "By Cond No w/ Data Points", "By Sample w/ Data Points", "Average by Condition w/ Data Points"},
		<<SetFunction( Function( {f2}, GetDPCharts = cbAllDPCharts << get selected ) ) ),
	),
	//Allow the user to select all charts
	H List Box(
	cbAll = Check Box( " ",
		<< Set Function(
			Function( {f3},
				cbAllCharts << Set All( f3 << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select All Curve Plots" ),
	Spacer Box( Size( 9, 0 ) ),
	cbAll2 = Check Box( " ",
		<< Set Function(
			Function( {f4},
				cbAllDPCharts << Set All( f4 << Get, run script( 1 ) )
			)
		),
	),
	Text Box( "Select all Points and Curve Plots" ),
	),
	H List Box( Button Box( "OK" ) )
);

//Place all selections into one list
if( N Items( GetDPCharts ) > 0,
	For( i = 1, i<= N Items( GetDPCharts ), i++,
		Insert Into( GetCharts, GetDPCharts[i] )
	)
);

Print( GetCharts, GetDPCharts );

View solution in original post

Highlighted
WendyLou315
Level III

Re: Check Box question with subgroups with select all of each subgroup fails

AWESOME! Thank you for the tutorial and furthering my JSL understanding and toolbox!
Article Labels

    There are no labels assigned to this post.