cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
sowiakg
Level I

Automate copying table scripts when rerunning "source"

Hi,

I am creating a database in Excel that will be continually updated. New rows and columns will be added periodically, and existing rows will occasionally have new data added. As such I have started making use of the "Source" script to update the corresponding downstream JMP table.

The question I have is, is there a way to bring over any existing table scripts to the updated table when running the Source script? I have a number of graph builder scripts saved to the JMP table and would like to automatically copy them over to the new table each time the Source script is run. I use JMP version 17.

Thank you!

4 REPLIES 4
txnelson
Super User

Re: Automate copying table scripts when rerunning "source"

Welcome to the community.

Here is an example of the code required to copy all of the table scripts from one data table to another, minus the Source table script.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
names=dt<<get table Script names;
remove from(names,1,1);
dt << Select Properties( names );
proplist = dt << Get Selected Properties();
dt2 = New Table( "Little Class" );
dt2 << Add scripts to table( proplist );

You would have to add this methodology to your Source script, or run it as a separate script to do what you are trying to do.

You can find details and examples of the different elements in this script in the Scripting Index under the Help pull down menu

Jim

Re: Automate copying table scripts when rerunning "source"

I know I just left another comment saying how I see your JMP help everywhere and it's really appreciated. But seriously. I see your help everywhere and it's so useful. Thanks for all you do to help people out.

jthi
Super User

Re: Automate copying table scripts when rerunning "source"

Here is other option

Names Default To Here(1);

// Depending on your source script, there are different options of handling // getting the reference to dt1 and dt2 dt1 = Open("$SAMPLE_DATA/Big Class.jmp"); dt2 = Open("$SAMPLE_DATA/Big Class Families.jmp");
dt2 << Delete Scripts(dt2 << Get Table Script Names); // for demo purposes wait(1); // for demo purposes
t_scripts = dt1 << Get Table Script Names; Remove From(t_scripts, Contains(t_scripts, "Source"), 1);
For Each({t_script}, t_scripts, Eval(EvalExpr( dt2 << New Script(t_script, Expr(dt1 << Get Script(t_script)); ); )); ); wait(0);
-Jarmo
hogi
Level XII

Re: Automate copying table scripts when rerunning "source"

Another approach:
Upgrade to JMP 18, it's free for all licensed users.

In JMP 18, besides the Source Script, there is an Update Script:

hogi_0-1724503652787.png

 

which will update the table itself - insted of creating a new one. Manually added scripts stay.

 

Pros of "Update Table" compared to "Source Scripts:
Source Scripts are "fragile" - JMP overwrites them without warning:
Update & Concatenate: source script collision 

 

Cons:
Update Table removes any manually added column

https://community.jmp.com/t5/JMP-Wish-List/Wizard-to-update-Excel-files-in-place-no-code-solution/id...