cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
katief
Staff (Retired)

Copying scripts from one data table to another

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

1 ACCEPTED SOLUTION

Accepted Solutions
Phil_Kay
Staff

Re: Copying scripts from one data table to another

@David_Burnham 's script for getting all scripts from a data table seemed to be missing a [i] on line 9:

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[i];

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

    Eval(Parse(Eval Insert( "\[

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

    ]\")));

)

View solution in original post

3 REPLIES 3
David_Burnham
Super User (Alumni)

Copying scripts from one data table to another

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 (Retired)

Copying scripts from one data table to another

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.

Phil_Kay
Staff

Re: Copying scripts from one data table to another

@David_Burnham 's script for getting all scripts from a data table seemed to be missing a [i] on line 9:

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[i];

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

    Eval(Parse(Eval Insert( "\[

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

    ]\")));

)