cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ENTHU
Level IV

Running a script multiple times with different inputs.

Hi

 

I have written a script which gets some data, does some manipulation(like sorting,ordering,subset etc) and finally plots the data.

Need to run this script several times with different inputs.How can I do this?

 

This is what I tried -

 

in_list = {};
in_list = Associative array(dtin:input) << get keys //this is to get all inputs into a list
 
for(i=1,i<Nitems(in_list),i++,
//put all the code here
);

 

But the script runs for only first input.

Also I save each output with different file name.

1 ACCEPTED SOLUTION

Accepted Solutions
cwillden
Super User (Alumni)

Re: Running a script multiple times with different inputs.

Don't hardcode the table name into the join.  Use a variable name instead.  E.g. don't use Data Table("Table Namen1") << Join("Table Name2",...), instead use dt << Join(dt2,...).  If you do that, you can have your data table variables always point to the correct data table for the current loop iteration. 

 

You should also make sure to close any intermediate data tables once you don't need them anymore just as you described in trying to solve your problem.  Keep JMP as uncluttered as possible.

-- Cameron Willden

View solution in original post

5 REPLIES 5
cwillden
Super User (Alumni)

Re: Running a script multiple times with different inputs.

Your missing a semicolon on the second line, but I assume you have one in your actual script.  The problem probably lies in side your loop (btw, the second argument of your for loop should probably be "<=" rather than "<" or you'll miss the last item in your list).  Here's a really simple example of a working script using your approach:

First, I made a table to get some inputs:table.PNG

 

 

Then I run this script:

dt = Current Data Table();
in_list = Associative Array(dt:input) << get keys;

for(i=1, i<=N Items(in_list), i++,
	Print(in_list[i]);
);

Here's the log output:logoutput.PNG

 

 It might help you to write a function that you can evaluate inside the loop with different values for the arguments each time.  This will allow you to develop and test the function outsidie the loop so it is easier to troubleshoot.

 

 

-- Cameron Willden
ENTHU
Level IV

Re: Running a script multiple times with different inputs.

Thanks for the response.

I figured that I have a stop() in a if statement inside for loop that is causing problems.

Replaced it with continue(),but that doesnt solve the problem.

Is there a function that can stop just the current iteration and continue with next?

 

Thanks

 

cwillden
Super User (Alumni)

Re: Running a script multiple times with different inputs.

You really shouldn't need any such thing.  If you are willing to post a more complete script, I can help you determine where your problem is.  Stop() completely terminates the execution of the entire script.  Break() terminates execution of a loop. Continue() is pretty much exactly what you described; it breaks the current iteration and returns to the top of the loop.

-- Cameron Willden
ENTHU
Level IV

Re: Running a script multiple times with different inputs.

Thanks for the reply. After further debug I figured the root cause of my problem.

Problem statement: While running in the loop,the input choice gets updated but the graph is the same for all input choice.

Root cause: I have joins in the script.So each time the script runs the tables are saved with suffix 1,2 so on.

But since the join logic has the original table name,the tables dont get updated.Each time the tables get joined with original tables(tables created on first run) and the output graph is the same.

 

Solution: I tried Try(close(out_table,no save)) but with no luck.

Any help in this regard is appreciated.

cwillden
Super User (Alumni)

Re: Running a script multiple times with different inputs.

Don't hardcode the table name into the join.  Use a variable name instead.  E.g. don't use Data Table("Table Namen1") << Join("Table Name2",...), instead use dt << Join(dt2,...).  If you do that, you can have your data table variables always point to the correct data table for the current loop iteration. 

 

You should also make sure to close any intermediate data tables once you don't need them anymore just as you described in trying to solve your problem.  Keep JMP as uncluttered as possible.

-- Cameron Willden