Loading jsl scripts into a data table by another scriptHi,
I have several scripts (XXX.jsl) generating seperate reports with many graphs inside each of these reports. And i have a second script which loads data from an exel file, modifies the resulting JMP table and saves the table.
I would be interested to include in the second script a section which loads these report scripts from a folder and makes these available in the upper left box of the JMP table.
I am doing this because I create a JMP script which should be used by my colleagues. They should just change the file path of the excel file and run the script. With that they should get the JMP table and based on their current table the option to run the reports.
I am sure there is an option, but currently approaches with e.g. include() failed or << save script to data table failed.
Automation and ScriptingRe: Loading jsl scripts into a data table by another scriptHere is simple example which adds text from a file to table as table script
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << Delete Scripts(dt << Get Table Script Names); // demo
script_txt = Load Text File("$SAMPLE_SCRIPTS/chaosGame.jsl");
Eval(EvalExpr(
dt << New Script("S",
Expr(Parse(script_txt))
);
));
If you wish to keep comments, it will be slightly more complicated.
Edit: Also if comments are not needed, you can use Include with << Parse Only
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
dt << Delete Scripts(dt << Get Table Script Names); // demo
script_expr = Include("$SAMPLE_SCRIPTS/chaosGame.jsl", << parse only);
Eval(EvalExpr(
dt << New Script("S",
Expr(Name Expr(script_expr))
);
));
Re: Loading jsl scripts into a data table by another scriptThank you very much for your quick reply.
Would it be possible that you explain this solution a bit more?
With "Names Default To Here(1); you set your local name space.
Then you open a jmp table and delete the scripts which came with the opened tabel, correct?
This is followed by the part dealing with the script which should be loaded. You define the variable script_txt and this should be the loaded text file from the given directory. What do the last five rows of code do, could you explain it a bit.
I always like to understand what the code does in detail. This helps me a lot to avoid simple but fatal errors during implementation.
Re: Loading jsl scripts into a data table by another scriptI suggest reading JMP Scripting Guide for the basics.
- Regarding Names Default To Here(1); you should just always start your scripts with it, Scripting Guide > Programming Methods > Advanced Scoping and Namespaces .
- Opening table and the removal of scripts are just for demo purposes to make it easier to show what is going on.
- Last parts are using expression evaluation to make sure you get the script into your table in correct format, for it to be easy to run, Scripting Guide > Programming Methods > Advanced Expressions, Macros, and Lists .
Re: Loading jsl scripts into a data table by another scriptGreat thank you it works! And thank you very much for the explanation.