cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
LBrian
Level III

How to setup Combo box list?

Hello.

I wanna make a list using combo box, showing ".csv" only.

How to setup the list?

 

In my code,

All files are listed up on selected directory.

 

Names Default To Here( 1 );
Load file = New Window( "New Window",
	<<modal(),
	<<ReturnResult,
	<<on close(
	), 

	H List Box(
		Text Box( "Choose directory" ),
		Spacer Box( size( 10, 10 ) ),
		BB1 = Button Box( "Load file", 
			address1 = Pick Directory();
				
			If( address1 == "",
				file1 << set text( "" ), //else if
				If( address1 != "",
					file1 << set text( address1 )
				)
			);
		)
	), 	
	

	Panel Box( "",
		V List Box( Text Box( "Directory path :" ), Spacer Box( size( 300, 10 ) ), file1 = Text Box( "" ) )
	)
);
	
path = address1;
address1 = Files In Directory( address1 );
			
	
nw = New Window( "Pick CSV Files",
	Panel Box( "List",
		Lineup Box( N Col( 2 ),
			Text Box( "1st:" ),
			cb1 = Combo Box( address1 ),		
			Button Box( "OK" );	
		)
	);
);
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to setup Combo box list?

All you need to do is to loop backwards through the address1 list and remove all of the entries that are not .csv files.

For( i = N Items( address1 ), i >= 1, i--,
	If( Word( -1, address1[i], "." ) != "csv",
		Remove From( address1, i, 1 )
	)
);

See the Scripting Index for definition and examples of any of the above used functions.

Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to setup Combo box list?

All you need to do is to loop backwards through the address1 list and remove all of the entries that are not .csv files.

For( i = N Items( address1 ), i >= 1, i--,
	If( Word( -1, address1[i], "." ) != "csv",
		Remove From( address1, i, 1 )
	)
);

See the Scripting Index for definition and examples of any of the above used functions.

Jim
LBrian
Level III

Re: How to setup Combo box list?

It works very well!

Thank you so much.

jthi
Super User

Re: How to setup Combo box list?

Also if you have JMP16+, you can use Filter Each

address2 = Filter Each({filename}, Files In Directory(address1),
	Ends With(filename, ".csv");
);
-Jarmo