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
klk
klk
Level III

Add Contents of script file as New Script to data table

I have a saved jmp script.  Let's call it my_graph.jsl.  I want to take that script and add it to my current data table as a New Script().  I know that

dt << New Script(scriptname, code)

will add a new script to the data table.  But it's not clear to me how to get the contents of my_graph.jsl and dump it in there.  I've tried playing around with Load Text File() but then I'm not sure what to do with that.  I imagine the solution will involve some combination of Eval/Expr/Eval Expr but honestly I've never wrapped my head around the order of those that make sense

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Add Contents of script file as New Script to data table

Here is one more option using Include(, << Parse Only)

 

Names Default To Here(1);

script_path = "$DOWNLOADS/table_script.jsl";

txt = "Graph Builder(
	Size(525, 454),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Color(:sex)),
	Elements(Points(X, Y, Legend(5)))
);";

Save Text File(script_path, txt);
txt = "";


dt = Open("$SAMPLE_DATA/Big Class.jmp");
Eval(EvalExpr(
	dt << New Script("Plot Graph", Expr(Include(script_path, << Parse Only)))
));

Some links regarding eval/eval expr and so on

 

  1. https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-...
  2. https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/ba... 
  3. https://community.jmp.com/t5/Discussions/Can-you-construct-this-without-writing-expression-as-a-stri... 
-Jarmo

View solution in original post

4 REPLIES 4
Byron_JMP
Staff

Re: Add Contents of script file as New Script to data table

Yep, that's a twisty one

 

maybe something like this?

obj=open("/Users/bywing/Byron Wingerd/Examples/eraseme.jsl");
stuff=obj<<get text;

dt=new table("Target");
ex=expr(dt<< new script("Stuffing", "XX" ));
substitute into( ex, "XX", parse(nameexpr(stuff)));
eval(ex);
JMP Systems Engineer, Health and Life Sciences (Pharma)
jthi
Super User

Re: Add Contents of script file as New Script to data table

Here is one more option using Include(, << Parse Only)

 

Names Default To Here(1);

script_path = "$DOWNLOADS/table_script.jsl";

txt = "Graph Builder(
	Size(525, 454),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Color(:sex)),
	Elements(Points(X, Y, Legend(5)))
);";

Save Text File(script_path, txt);
txt = "";


dt = Open("$SAMPLE_DATA/Big Class.jmp");
Eval(EvalExpr(
	dt << New Script("Plot Graph", Expr(Include(script_path, << Parse Only)))
));

Some links regarding eval/eval expr and so on

 

  1. https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-...
  2. https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/ba... 
  3. https://community.jmp.com/t5/Discussions/Can-you-construct-this-without-writing-expression-as-a-stri... 
-Jarmo
Byron_JMP
Staff

Re: Add Contents of script file as New Script to data table

"<<Parse Only"  Nice!

JMP Systems Engineer, Health and Life Sciences (Pharma)
klk
klk
Level III

Re: Add Contents of script file as New Script to data table

This is perfect, thank you!