cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
Jo_E
Level II

Loading jsl scripts into a data table by another script

Hi,
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. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Loading jsl scripts into a data table by another script

Here 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))
	);
));

 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: Loading jsl scripts into a data table by another script

Here 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))
	);
));

 

-Jarmo
Jo_E
Level II

Re: Loading jsl scripts into a data table by another script

Thank 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.

jthi
Super User

Re: Loading jsl scripts into a data table by another script

I suggest reading JMP Scripting Guide for the basics.

 

  1. Regarding Names Default To Here(1); you should just always start your scripts with it,  Scripting Guide > Programming Methods > Advanced Scoping and Namespaces .
  2. Opening table and the removal of scripts are just for demo purposes to make it easier to show what is going on.
  3. 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 . 
-Jarmo
Jo_E
Level II

Re: Loading jsl scripts into a data table by another script

Great thank you it works! And thank you very much for the explanation.

Recommended Articles