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

Open multiple data file and run each with assigned script

Hi All,

I have the following script that will prompt to open a data file and then a script to auto run once I hit OK box.

Names Default To Here( 1 );
New Window( "Data and Limits file",
	<<modal,
	Spacer Box( size( 10, 10 ) ),
	Text Box( "Choose A Data File:" ),
	
	// below showing directory of D:\JMP_test
	BB1 = Button Box( "Pick file",
		D = Pick File("Pick a file","D:\JMP_test");
		
		If( D != "",
			file1 << set text( D )
			
		);
	),
	
	file1 = Text Box( ), 
	Spacer Box( size( 20, 10 ) );,
	Text Box( "Choose A Script to Autorun:" ),
	// below showing directory of D:\JSL
	BB2 = Button Box( "Pick File",
		L = Pick File("Pick a file","D:\JSL");
		If( L != "",
			file2 << set text( L )
		);
	),
	file2 = Text Box(  ), 
	Spacer Box( size( 20, 10 ) ) 

	;
);
dt = Open (D);
dt2 = Open ((L),Run JSL(1)) ;

If I intended to open more than one data file (2 files at once) and then run individual script assign to it, how to do it with jsl. For example, datatable1 will run with script1 and datable2 is assigned to run with script2

 

Thank you.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: Open multiple data file and run each with assigned script

Oh, boy!  That type of interface seems fraught with issues. What if the user picks 10 data files and only 8 scripts, or vice versa? What if the user wants to run 3 different scripts (analyses) on one file, or selects 10 data files but wants to run the same analyses on each?  I do not know your use case, however, I'd create a dialog, with 3 items in a horizontal display: 1) a selection list of the the files in D:/Test , 2) a button box, called "Select" or "Analyze", and 3) a selection list with the scripts on the right.

 

The user selects the intended files on each side, then presses the "Select" button. Each select would create a list of two items, a list of the selected data files and a list of the scripts and store them another list called sel_List (or other object, an associative array or data table). The intent is each script is run on each data file for a given selection. If your use files are 1:1 then allow only one selection in each list box, i.e., select one data file, select one jsl file, then press "Select."

 

Pressing "Ok" would begin processing on each selection, using nested for loops: 

  •  For(i=1, i<=nitems(sel_List), i++,
  •    For(j=1, j<=nitems(sel_List[i][1]), j++,  //open (sel_List[i][1][j] );  //open a data table
  •      For(k=1, k<=nitems(selList[i][2]), k++, 
  •         Include(sel_List[i][2][k]);   // include runs on the current data table
  •            Save/or journal and likely close analysis windows
  •     ); // end for k. By using include the JSL file is executed but not open.
  •  );  //end for j  close(selList[i][1][j]) close the data table
  • ); // end for i

If you are using JMP 14, Multiple File Import() might be of some use.

 

I attached a script (has the name App, but is not an addin) that does not have the interface described above, but might give you some ideas on how to create the selection window. [It was written for chapter 2 of JSL Companion].

 

Good Luck!

 

If there really is only 1 script associated for each file or file type, then I wouldn't have the user select it, but build in the logic with naming conventions etc.  

 

Anyway, my 2 cents.

View solution in original post

2 REPLIES 2
gzmorgan0
Super User (Alumni)

Re: Open multiple data file and run each with assigned script

Oh, boy!  That type of interface seems fraught with issues. What if the user picks 10 data files and only 8 scripts, or vice versa? What if the user wants to run 3 different scripts (analyses) on one file, or selects 10 data files but wants to run the same analyses on each?  I do not know your use case, however, I'd create a dialog, with 3 items in a horizontal display: 1) a selection list of the the files in D:/Test , 2) a button box, called "Select" or "Analyze", and 3) a selection list with the scripts on the right.

 

The user selects the intended files on each side, then presses the "Select" button. Each select would create a list of two items, a list of the selected data files and a list of the scripts and store them another list called sel_List (or other object, an associative array or data table). The intent is each script is run on each data file for a given selection. If your use files are 1:1 then allow only one selection in each list box, i.e., select one data file, select one jsl file, then press "Select."

 

Pressing "Ok" would begin processing on each selection, using nested for loops: 

  •  For(i=1, i<=nitems(sel_List), i++,
  •    For(j=1, j<=nitems(sel_List[i][1]), j++,  //open (sel_List[i][1][j] );  //open a data table
  •      For(k=1, k<=nitems(selList[i][2]), k++, 
  •         Include(sel_List[i][2][k]);   // include runs on the current data table
  •            Save/or journal and likely close analysis windows
  •     ); // end for k. By using include the JSL file is executed but not open.
  •  );  //end for j  close(selList[i][1][j]) close the data table
  • ); // end for i

If you are using JMP 14, Multiple File Import() might be of some use.

 

I attached a script (has the name App, but is not an addin) that does not have the interface described above, but might give you some ideas on how to create the selection window. [It was written for chapter 2 of JSL Companion].

 

Good Luck!

 

If there really is only 1 script associated for each file or file type, then I wouldn't have the user select it, but build in the logic with naming conventions etc.  

 

Anyway, my 2 cents.

adam
Level IV

Re: Open multiple data file and run each with assigned script

Thank you gzmorgan0.
I will make it something like use files are 1:1 then allow only one selection in each list box, i.e., select one data file. The script you attached is useful for me to explore the concept.