cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

As the tile says - I have tried the following but does not work

Names Default To Here( 1 );
// use the save-script-to-script-window button 
// in the MFI dialog to see more messages
// for filtering files and controlling the import
Multiple File Import( Keep Dialog Open (0),
	<<Set Folder( "$DESKTOP" ),
	<<Set Name Filter( "*.csv;" ),
	<<Set Name Enable( 1 )
) << Create Window;

Where am I going wrong?

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

Slight modification is needed (and is better for JMP17 also) as JMP17 has different default value change << Set to << Set All

Names Default To Here(1);

mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
) << Create Window;

// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (mfi << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);
-Jarmo

View solution in original post

17 REPLIES 17
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

You could navigate to the check box and control it that way

Names Default To Here(1);

mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
) << Create Window;

// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (mfi << XPath("//CheckBoxBox")); 
checkboxes[N Items(checkboxes)] << Set(0);

 

-Jarmo
Neo
Neo
Level VI

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

@jthi  Thanks but does not work in JMP 16.2.0 (on Windows 10)

When it's too good to be true, it's neither
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

Slight modification is needed (and is better for JMP17 also) as JMP17 has different default value change << Set to << Set All

Names Default To Here(1);

mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
) << Create Window;

// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (mfi << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);
-Jarmo
Neo
Neo
Level VI

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

@jthi  Your code works for me but I have a connected problem. It appears that the code proceeds without the user pressing the import button.   In my case (JMP 16.2 on Win10), the window tilte is shown and the journal window pops up. How to hold progress until the user has pressed the import button.

Names Default To Here(1);

mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
) << Create Window;

// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (mfi << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

mfi<< Get Window Title(); show (mfi);
jrnW  = New Window( "Report", << journal); 
When it's too good to be true, it's neither
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

You might be able to get Multiple File Import inside modal window somehow or you could try using << On Close

Names Default To Here(1);

mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
);
w = mfi << Create Window;

w << on close(
	jrnW  = New Window( "Report", << journal);
);

// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);
-Jarmo
Neo
Neo
Level VI

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

@jthi . Thanks. On Close only appear to work in case of the journal window. Does not work for the following for example.

Names Default To Here(1);
mfi = Multiple File Import(
	<<Set Folder("$DESKTOP"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
);
w = mfi << Create Window;
w << on close(
	mfi<< Get Window Title(); show (mfi);
);
// Check box with text box saying 'Keep dialog open' is last checkbox
checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

I need a run a large script after the user selects the files using the Multiple File Import function. The script operates on the selected files. Could I please have the example with  Multiple File Import function inside a Modal Window? In this case, how to reference he files opened by Multiple File Import  (in my case two files) for further use?

 

When it's too good to be true, it's neither
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

Most likely it won't work in your case as the mfi has been closed. I would go with On Close route because modal window will most likely mess up the buttons of Multiple File Import

Names Default To Here(1);

aa_olddt = Associative Array(Get Data Table List() << get name);

mfi = Multiple File Import(
	<<Set Folder("$SAMPLE_DATA"),
	<<Set Name Filter("*.csv;"),
	<<Set Name Enable(1)
);

w = mfi << Create Window();

checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

w << On Close(
	aa_newdt = Associative Array(Get Data Table List() << get name);
	aa_newdt << Remove(aa_olddt);
	dt_list = aa_newdt << get keys;
	Caption(dt_list);
);
-Jarmo
Neo
Neo
Level VI

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

@jthi Thanks, but how does one call further scripts (e.g to plot etc) to operate on the data tables imported. The first one below works, but this is not what I need.

Names Default To Here(1);
//clear log ();

aa_olddt = Associative Array(Get Data Table List() << get name);

mfi = Multiple File Import(
	<<Set Folder("$SAMPLE_DATA"),
	<<Set Name Filter("Big*"),
	<<Set Name Enable(1)
);

w = mfi << Create Window();

checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

w << On Close(
	aa_newdt = Associative Array(Get Data Table List() << get name);
	aa_newdt << Remove(aa_olddt);
	dt_list = aa_newdt << get keys;
	show (dt_list);
	dt = dt_list[1]; 
	dt = data table (dt);
	dt<<Distribution( Column( :Age, :Weight ) );
	//include ("plotDist.jsl");
	);

I need to be able to call scripts to operate on the imported data files. One below does not work (gives attached error)

Names Default To Here(1);
//clear log ();

aa_olddt = Associative Array(Get Data Table List() << get name);

mfi = Multiple File Import(
	<<Set Folder("$SAMPLE_DATA"),
	<<Set Name Filter("Big*"),
	<<Set Name Enable(1)
);

w = mfi << Create Window();

checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

w << On Close(
	aa_newdt = Associative Array(Get Data Table List() << get name);
	aa_newdt << Remove(aa_olddt);
	dt_list = aa_newdt << get keys;
	show (dt_list);
	dt = dt_list[1]; 
	dt = data table (dt);
	//dt<<Distribution( Column( :Age, :Weight ) );
	include ("plotDist.jsl");
	);
	
	//include ("plotDist.jsl");

where plotDist.jsl (saved in the same directory) is 

Names Default To Here(1);
dt<<Distribution( Column( :Age, :Weight ) );

Putting 

include ("plotDist.jsl");

outside On Close also does not work. Where am I going wrong?

When it's too good to be true, it's neither
jthi
Super User

Re: How to start Multiple File Import () vis JSL with Keep Dialog Open unchecked?

Names (strings) of datatables are stored to dt_list so you have to convert them to data table references when using.

Names Default To Here(1);
//clear log ();

aa_olddt = Associative Array(Get Data Table List() << get name);

mfi = Multiple File Import(
	<<Set Folder("$SAMPLE_DATA"),
	<<Set Name Filter("Big*"),
	<<Set Name Enable(1)
);

w = mfi << Create Window();

checkboxes = (w << XPath("//CheckBoxBox"));
checkboxes[N Items(checkboxes)] << Set All(0);

w << On Close(
	aa_newdt = Associative Array(Get Data Table List() << get name);
	aa_newdt << Remove(aa_olddt);
	dt_list = aa_newdt << get keys;
	Datatable(dt_list[1]) << Distribution(Column(:Age, :Weight));
);

Depending on your application it might be a good idea to loop over the dt_list (maybe rename it to dtname_list) and create a list of datatable references

-Jarmo