BookmarkSubscribeRSS Feed
mwechtal

Community Trekker

Joined:

Jan 19, 2012

Restricting Col List Box entries

I have a problem with Col List Box. I'd like to restrict the list of columns available to be selected.

I've already restricted it to Numeric and Continuous, but in my application that leaves a very long list.

For that matter, if there is another way that's easier (Column Dialog?), that would be fine too. The documentation seems limited on this. For instance, it shows that a script can be added to the Col List Box() function, but does not have an example, or describe how that would be done.

 

Using a modified example from the Scripting Index, how would I, for example, remove all column names that start with an N?

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );
New Window( "Col List Box Example 3",
	H List Box(
		ll1 = Col List Box( all,
			<< Set Data Type( "Numeric" ),
			<< Set Analysis Type( "Continuous" )),
		Button Box( "Add", ll2 << append( ll1 << get selected ) ),
		ll2 = Col List Box( "numeric", MaxItems( 1 ), nlines( 1 ) ),
		Button Box( "Remove", ll2 << remove selected )
	)
);
2 ACCEPTED SOLUTIONS

Accepted Solutions
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Solution

Re: Restricting Col List Box entries

@mwechtal

   How about something like this ? 

 

dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

ColumnNames = dt << Get Column Names("String"); 

for(i = N Items(ColumnNames), i >= 1 , i--,
		If(!IsMissing(Regex(Char(ColumnNames[i]),"PNP*")),
			Remove From(ColumnNames,i); 
		  );
   );
ColumnNames; 

New Window( "Example", b = Button Box( "Popup Menu", Print( b << Get Menu Choice ) ) );
b << set menu items(ColumnNames);
Best
Uday
vince_faller

Super User

Joined:

Mar 17, 2015

Solution

Re: Restricting Col List Box entries

Check out filter col selector(). 

 

Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
new window("Test", 
	fcs = filter col selector(dt)
);

It gives you a lot of options for reduction.  

4 REPLIES
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Solution

Re: Restricting Col List Box entries

@mwechtal

   How about something like this ? 

 

dt = Open( "$SAMPLE_DATA/Semiconductor Capability.jmp" );

ColumnNames = dt << Get Column Names("String"); 

for(i = N Items(ColumnNames), i >= 1 , i--,
		If(!IsMissing(Regex(Char(ColumnNames[i]),"PNP*")),
			Remove From(ColumnNames,i); 
		  );
   );
ColumnNames; 

New Window( "Example", b = Button Box( "Popup Menu", Print( b << Get Menu Choice ) ) );
b << set menu items(ColumnNames);
Best
Uday
mwechtal

Community Trekker

Joined:

Jan 19, 2012

Re: Restricting Col List Box entries

That wasn't exactly what I was thinking of, but it works!
vince_faller

Super User

Joined:

Mar 17, 2015

Solution

Re: Restricting Col List Box entries

Check out filter col selector(). 

 

Names default to here(1);
dt = open("$SAMPLE_DATA\Big Class.jmp");
new window("Test", 
	fcs = filter col selector(dt)
);

It gives you a lot of options for reduction.  

mwechtal

Community Trekker

Joined:

Jan 19, 2012

Re: Restricting Col List Box entries

This will also work. I knew about filtering, but hadn't thought about scripting it.