cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
geoff1
Level II

How to pass arguments to different jsl script ?

Hello,

I have a SQL database where we register data for different customers (and each customer has many tools).
I am in the process to create an automatic reports to monitor the tools performance from the SQL DB.
For one customer, I have a long script working (one long JSL) that connect to the SQL, run a query, save the table from the query, then modify/filter the table to get the data I need, then draw a few charts and save the results in a specific locations.

In order to make it more simple to use, for maintenance and upgrade, I would like create different JSL scripts and use the Customer_Tool_Info.txt file ( see example attachedin the Zip) as a configuration file.
As we have a lot of customers then I could simply use a For loop using this config file to create all the reports we need.
The Customer_Tool_Info.txt contains information for customer, tools and the infos for the ODBC connection.
What I would like is to have the main script to open the Customer_Tool_Info.txt and extract the needed infos and pass them as arguments for the other sub-scripts. 

  1. Main_script.jsl ( Get the arguments to pass to the Sub-scripts)
  2. Sub-scripts :
    1. Get_Data_from SQL.jmpquery
    2. FIlter_the_Table.jsl
    3. Get_Charts.jsl

Is it possible to pass arguments into different jsl scripts ? how? I tried in the Main_Script.jsl to explain all I want to do.
Please let me know if you have any questions and thank you for your help.
Regards
Geof


1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: How to pass arguments to different jsl script ?

You can pass the information to other JSL scripts via global variables.  These have the prefix "::"; I add a g to indicate that they're global.  For example:

::g_my_var = "Hello";
include("my_script.jsl");

View solution in original post

3 REPLIES 3
pmroz
Super User

Re: How to pass arguments to different jsl script ?

You can pass the information to other JSL scripts via global variables.  These have the prefix "::"; I add a g to indicate that they're global.  For example:

::g_my_var = "Hello";
include("my_script.jsl");
geoff1
Level II

Re: How to pass arguments to different jsl script ?

It works fine with gobal variables ! Thanks
Craige_Hales
Super User

Re: How to pass arguments to different jsl script ?

If you don't want to use global variables, use the include files to define functions and only include the files once, probably at the beginning of your main file. Then you can call the user defined functions with parameters. Something like this:

 

Main.jsl

--------

 

include("sub1.jsl");
include("sub2.jsl");
calculator(42);
reportWriter("report title");

 

 

sub1.jsl

-------

 

reportWriter = function({title},{i,j,k}, // i,j,k are local variable examples
write(title,"this is my report")
);

 

sub2.jsl

----

 

calculator = function({thresholdNumber},{x,y,z},
return(sqrt(thresholdNumber));
)

 

 

Craige