cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
sanqub
Level III

How do I make combo box to show unique values?

Dear All,

This script is similar to one in book "JUMP into JMP".

The script prompts user to select a "DCM", based on this selection "DieNo" list is populated.

There are couple of problems here. "DCM Number" list is not in ascending order.

Other issue, When I select a DCM number, "DieNo" list is populated. But this lists all the values, I want only unique values to be listed.

For both columns data type is char, however numeric datatype doesn't work here. Any advice on this problem.

 

/* Open the sample data table */
dt = Open( "$Desktop/JMP scripts/SampleData.jmp" );

/* Create lists of the values found in the DCMNo and Die columns*/
Unique DCM=Associative array(dt:DCMNo);
nitems(unique DCM);
DCM1= unique DCM<<get keys;
DCM=Sort Ascending(DCM1);
Unique Die=Associative array(dt:DieNo);
nitems(unique Die);
Die= unique Die<<get keys;
dt << Clear Column Selection();
dt << Clear row Selection();

/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
	hb = H List Box(
		Panel Box( "Select a DCM Number",
			select1 = Combo Box(
				DCM,  
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
				dt << Select Where( :DCMNo == DCM[select1 << get] );
				selRows = dt << Get Selected Rows;
				pb << delete;
				myDies = {};
/* The myDies list is populated with values from the selected DCMNo. */
				For( i = 1, i <= N Row( selRows ), i++,
					Insert Into( myDies, Column( dt, "DieNo" )[selRows[i]] )
				);
/* A new panel box is drawn and values shown are based on DCMNo selection. */
				hb << Append( pb = Panel Box( "Select a Die", select2 = Combo Box( myDies ) ) );
			)
		),
		pb = Panel Box( "Select a Die", Combo Box( " " ) )
	),  
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
	Button Box( "OK",
		nw << Close Window;
		dt << Select where( :DCMNo == DCM[select1 << get] & :DieNo == myDies[select2 << get] );
/* Selected rows are subsetted into new table. */
		rows=dt << get selected rows;
		dt << subset( Output Table Name( "Ryobi Details" ) );
	)
);

 

I am also trying to include date selection combo box. The best post and easy option for this was "date data filter".

Does JMP allow me to show a calender for dates {A wee calender as shown when we book flights from depature date to arrival date}.

 

Cheers

 

San

10 REPLIES 10
pmroz
Super User

Re: How do I make combo box to show unique values?

The scripting index and guide are somewhat weak with regard to this new function.  The examples in the scripting guide could be beefed up a bit.  Here's a better one that displays the calendar.  When you select a date and click OK that is printed in the log window.

Names Default To Here( 1 );
nw = New Window( "Calendar Box Example", 
	cal = Calendar Box(),
	ok_button = button box("OK",
		selected_date = format(cal << get date, "ddMonyyyy");
		print(selected_date);
		nw << close window;
	)
);