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
Rajat
Level IV

Dialog Box to select multiple type of csv file.

Hi all,

 

I want to create a dialog box which asks user to select 2 files.

 

I could use use pick file function but I want to create a dialog box which picks the file in one shot otherwise pick have to run multiple times.

 

I want dialog similar to shown in image. 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
ian_jmp
Staff

Re: Dialog Box to select multiple type of csv file.

If you want an interface that's like your sketch, here's a start. At the moment you could select the same file to play both roles, but that's probably not what you want.

NamesDefaultToHere(1);

// Get a list of folders and directories
myFiles = FilesInDirectory("$Desktop");

// Only keep .csv files
for(f = NItems(myFiles), f >=1, f--,
	thisOne = myFiles[f];
	if (!IsFile(thisOne) | !EndsWith(thisOne, ".csv"), RemoveFrom(myFiles, f));
	);
if(Nitems(myFiles) < 2, Print("Not enough .CSV files found"); Beep(); Throw());

// Make a user interface
nw = 
NewWindow("Pick Two Files",
	LineUpBox(NCol(2),
		TextBox("   Pick File 1:"),
		cb1 = ComboBox(myFiles),
		TextBox("   Pick File 2:"),
		cb2 = ComboBox(myFiles)
		),
	ButtonBox("OK", OKscript);
	);

// Runs when 'OK' button is pressed
OKscript =
Expr(
	nw << closeWindow;
	f1 = myFiles[cb1 << get];
	f2 = myFiles[cb2 << get];
	Print(f1, f2);
	); 

View solution in original post

3 REPLIES 3
Highlighted
txnelson
Super User

Re: Dialog Box to select multiple type of csv file.

The Pick File has a "Multiple" option that allows for the selection of multiple files

See:

     Help==>Scripting Index==>Pick File

Jim
Highlighted
ian_jmp
Staff

Re: Dialog Box to select multiple type of csv file.

If you want an interface that's like your sketch, here's a start. At the moment you could select the same file to play both roles, but that's probably not what you want.

NamesDefaultToHere(1);

// Get a list of folders and directories
myFiles = FilesInDirectory("$Desktop");

// Only keep .csv files
for(f = NItems(myFiles), f >=1, f--,
	thisOne = myFiles[f];
	if (!IsFile(thisOne) | !EndsWith(thisOne, ".csv"), RemoveFrom(myFiles, f));
	);
if(Nitems(myFiles) < 2, Print("Not enough .CSV files found"); Beep(); Throw());

// Make a user interface
nw = 
NewWindow("Pick Two Files",
	LineUpBox(NCol(2),
		TextBox("   Pick File 1:"),
		cb1 = ComboBox(myFiles),
		TextBox("   Pick File 2:"),
		cb2 = ComboBox(myFiles)
		),
	ButtonBox("OK", OKscript);
	);

// Runs when 'OK' button is pressed
OKscript =
Expr(
	nw << closeWindow;
	f1 = myFiles[cb1 << get];
	f2 = myFiles[cb2 << get];
	Print(f1, f2);
	); 

View solution in original post

Highlighted
Rajat
Level IV

Re: Dialog Box to select multiple type of csv file.

Thanks @ian_jmp
Article Labels

    There are no labels assigned to this post.