Subscribe Bookmark RSS Feed

Copying scripts from one data table to another

katief

Staff

Joined:

Oct 21, 2011

I would like to be able to take scripts stored in one table (A) and use them in another table (B). How can I do this? I'll need to be able to code this in JSL.

Alternatively, how could I add a script that's stored on my computer (a JSL file) to a data table?

This is similar to another user's question that was answered about adding a script from a graph to a table. Unfortunately, I don't think I can use the Get Script command in my situation because I don't want the script that made the table, I want a script stored in the table.

Thank you!

Katie

2 REPLIES
David_Burnham

Super User

Joined:

Jul 13, 2011

If you want to copy a specific script you can use the following code:

     dt = Open("$SAMPLE_DATA/Big Class.jmp");

     scriptName = "Oneway";

     scriptDef = dt << get table variable(scriptName);

     dt2 = new table("little class");

     Eval(Parse(Eval Insert( "\[

          dt2 << New Script( "^scriptName^", ^scriptDef^ )

     ]\")));

If you want to copy all of the scripts then you can do this:

dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt2 = new table("little class");

lstScriptNames = dt << Get Table Script Names;

For (i=1,i<=NItems(lstScriptNames),i++,

    scriptName = lstScriptNames;

    scriptDef = dt << get table variable(scriptName);

    Eval(Parse(Eval Insert( "\[

          dt2 << New Script( "^scriptName^", ^scriptDef^ )

    ]\")));

)

-Dave

-Dave
katief

Staff

Joined:

Oct 21, 2011

Thank you very much!  This worked.

I think a nice feature to add to JMP would be to allow scripts to be added to JMP tables as files or references- eliminate the need for the eval statement.