- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-...
- https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/ba...
- https://community.jmp.com/t5/Discussions/Can-you-construct-this-without-writing-expression-as-a-stri...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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
- https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-...
- https://community.jmp.com/t5/JMPer-Cable/Expression-Handling-Functions-Part-I-Unraveling-the-Expr/ba...
- https://community.jmp.com/t5/Discussions/Can-you-construct-this-without-writing-expression-as-a-stri...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Contents of script file as New Script to data table
"<<Parse Only" Nice!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Contents of script file as New Script to data table
This is perfect, thank you!