There are different ways of doing things in JMP so I'm not going to comment on "best" ways. But JMP has the ability to easily save scripts to tables. These scripts allow you to re-generate an analysis that you have performed with a specific platform. So if I have a table and make create an overlay plot, then rather than save the overlay plot (as a file) I can instead simply save the script to the data table. Then I can rerun the script to regenerate the graph.
In your example you have a script to generate a table (via concatenation etc) so it can often be convenient to use that script to append a script to the table which you do using the New Script (or New Table Script or Table Property - same thing, they are synonyms).
BUT - the 2nd argument needs to be the script itself, not a variable referring to the script. In your example a table script will be created that contains the single word "plot" whereas you want to entire specification for the overlay plot.
dt << New Table Script( "IdVg",
Overlay Plot(
X(:Name("Vg (V)")), Y( :Name("Id(A/mm)"), :Name("gm (mS/mm)")),
Y Scale (Left,Right),
)
);
Here's an example:
dt1 = Open("$SAMPLE_DATA/Fitness.jmp");
// create some sort of derived table
someRows = dt1 << Get Rows Where(:sex=="F");
dtNew = dt1 << Subset(Rows(someRows));
// then append a script to it
dtNew << New Script( "My New Script",
Overlay Plot(
X( :Runtime ),
Y( :Oxy ),
Separate Axes( 1 )
)
);
If you name the script "OnOpen" then the script will automatically run when the table is opened.
-Dave