cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Register for May 2 Mastering JMP Demo - Circumventing Common Pitfalls in Predictive Modeling
Choose Language Hide Translation Bar
View Original Published Thread

Multifile Import in a script / workflow

hogi
Level XII

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:

  1. Pause the script till the import is ready:
    - use a while loop
    - stop it via
    Set Import Callback
    finished= 0;
    mfi = Multiple File Import(
    	<<Set Import Callback( finished=1)
    );
    
    my win = mfi << createwindow;
    while(not(finished), wait(1));
  2. get a list of the imported data tables:
    via _wfb_Listdiff() (from Workflow Builder):
    _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 );

     

  3. if there is no data ..

    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?
    so: Throw(). 
    hogi_0-1744469787929.png

     



  4. The user can close the MFI dialog via 

    hogi_0-1744468837328.png
    then the while loop will run forever (or: till the user presses ESC)
    -> add an on close script:
    my win = mfi << createwindow;
    wait(0);
    current window() << on close(finished=1)
4 REPLIES 4
Craige_Hales
Super User


Re: Multifile Import in a script / workflow

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.

 

Craige
hogi
Level XII


Re: Multifile Import in a script / workflow

hi @Craige_Hales 

 

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.

Craige_Hales
Super User


Re: Multifile Import in a script / workflow

Make sure the category selector shows objects (or all.)

Craige_Hales_0-1744545152791.png

 

 

Craige
hogi
Level XII


Re: Multifile Import in a script / workflow

: )