What is the best way to use Multi File Import in a script?
[I want to give the user the chance to edit the settings and then click on Import.]
My current approach:
finished= 0;
mfi = Multiple File Import(
<<Set Import Callback( finished=1)
);
my win = mfi << createwindow;
while(not(finished), wait(1));
_wfb_ListDiff = Function( {tempOld, tempNew},
For( i = 1, i <= N Items( tempOld ), i++,
For( k = N Items( tempNew ), k >= 1, k--,
If( tempOld[i] == tempNew[k],
Remove From( tempNew, k, 1 )
)
)
);
tempNew;
);
Custom_step_tables_old = Get Data Table List();
MFI();
while(no(finished), wait());
Custom_step_tables_new = Get Data Table List();
dts = _wfb_ListDiff( Custom_step_tables_old, Custom_step_tables_new );
To stop the execution of subsequent code, check
if (items(dts) ==0, Throw("no data"));
did you know that stop() inside a Workflow step just stops the execution of the current step?
The user can close the MFI dialog via
my win = mfi << createwindow;
wait(0);
current window() << on close(finished=1)
You should be able to get the list of imported tables from the callback function, look at the SetImportCallback example.
If JSL does the <<ImportData, that also returns a list of tables. But in your case, the user presses a button and the callback is the only way to report them.
As an alternative, I changed the behavior of the Import button:
my win[ButtonBox(8)] << set function (dts = mfi << Import Data(); wait(0); finished=1);
But, unfortunately, the original import is triggered as well.
... so I replaced the import button with an alternative one:
my win = mfi << createwindow;
my win[ButtonBox(8)] << sib append (Button Box ("Import +",dts = mfi << Import Data(); wait(0); my win << close window()));
my win[ButtonBox(8)] << delete
What example are you referring to, I couldn't find it.
Make sure the category selector shows objects (or all.)
: )