BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Hegedus

Community Trekker

Joined:

Jun 23, 2011

How to Set a Check Box to default on?

Hi,

 

I am building a simple interface for the user and have a window to set some options using check boxes.  I would like to have the boxes checked by default.  How is this done.  The manual mentions a depreciated dialog box that allows setting of a default and recommends using modal window instead.  There appears to be no straightforward method described in the manual to achieve same functionality.

 

How should it be done?

 

Andy

New Window( "Input Required", <<Modal,
VlistBox(align("Center"),
	Text Box("Set Preferences"),
	Pref =Check Box({"Remove Single Value","Remove Duplicates","Group by Name"},1),
	spacer box(size(200,20)), 
 
 Hlistbox(2, 
	Button Box( "OK",
		RV=Pref<<get(1);
		RD=Pref<<get(2);
		GR=Pref<<get(3);

	),
	Button Box( "Cancel",
		stop();
	)
	))
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: How to Set a Check Box to default on?

Here is an example setting your first check box to being on

New Window( "Input Required", <<Modal,
VlistBox(align("Center"),
	Text Box("Set Preferences"),
	Pref =Check Box({"Remove Single Value","Remove Duplicates","Group by Name"},1),
	spacer box(size(200,20)), 
	pref<<set(1,1);
 
 Hlistbox(2, 
	Button Box( "OK",
		RV=Pref<<get(1);
		RD=Pref<<get(2);
		GR=Pref<<get(3);

	),
	Button Box( "Cancel",
		stop();
	)
	))
);
Jim
8 REPLIES 8
txnelson

Super User

Joined:

Jun 22, 2012

Solution

Re: How to Set a Check Box to default on?

Here is an example setting your first check box to being on

New Window( "Input Required", <<Modal,
VlistBox(align("Center"),
	Text Box("Set Preferences"),
	Pref =Check Box({"Remove Single Value","Remove Duplicates","Group by Name"},1),
	spacer box(size(200,20)), 
	pref<<set(1,1);
 
 Hlistbox(2, 
	Button Box( "OK",
		RV=Pref<<get(1);
		RD=Pref<<get(2);
		GR=Pref<<get(3);

	),
	Button Box( "Cancel",
		stop();
	)
	))
);
Jim
Hegedus

Community Trekker

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

Thank you,.

I would suggest you add some verbiage to the manual to explain this.
txnelson

Super User

Joined:

Jun 22, 2012

Re: How to Set a Check Box to default on?

You need to add this request to the JMP Wish List.  I, like you, am just a JMP user, not an employee for JMP.

Jim
markbailey

Staff

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

There is already a solution in the scripting guide, by the way:

 

Capture.PNG

Learn it once, use it forever!
Highlighted
Hegedus

Community Trekker

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

I am using JMP 12 and I did a search of the scripting guide and your example was not found. Perhaps it only exists in the latter versions.
pmroz

Super User

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

This version sets all of the checkboxes to checked, regardless of how many are in your list.

New Window( "Input Required", <<Modal,
	V List Box(
		align( "Center" ),
		Text Box( "Set Preferences" ),
		Pref = Check Box( {"Remove Single Value", "Remove Duplicates", "Group by Name"}),
		Spacer Box( size( 200, 20 ) ),
		H List Box(
			Button Box( "OK",
				RV = Pref << get( 1 );
				RD = Pref << get( 2 );
				GR = Pref << get( 3 );
			),
			Button Box( "Cancel", Stop() )
		),
	),
	pref_list = pref << get items;
	for (i = 1, i <= nitems(pref_list), i++,
		pref << set(i, 1);
	),
);
markbailey

Staff

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

Ha! Never mind. Yes, you do need the iteration in this case.

 

Ignore: Do you need the explicit iteration at the end? Just send the message to the list and it will distribute it to each of its items.

(pref << get items) << set( 1 );

 

Learn it once, use it forever!
pmroz

Super User

Joined:

Jun 23, 2011

Re: How to Set a Check Box to default on?

Sorry Mark but that doesn't work.  I should have checked (ar ar ar) the scripting index.  Use set all.

New Window( "Input Required", <<Modal,
	V List Box(
		align( "Center" ),
		Text Box( "Set Preferences" ),
		Pref = Check Box( {"Remove Single Value", "Remove Duplicates", "Group by Name"}),
		Spacer Box( size( 200, 20 ) ),
		H List Box(
			Button Box( "OK",
				RV = Pref << get( 1 );
				RD = Pref << get( 2 );
				GR = Pref << get( 3 );
			),
			Button Box( "Cancel", Stop() )
		),
	),
	pref << set all(1)
);