cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
miguello
Level VI

How to update table script

What is the most reliable way of updating table script?

 

Let's say I have a script that saves a snippet of a script into a table as table script and gives it a name "Script". Let's say, I run that script again and it again saves an updated snippet as table script - it will add " 2" to "Script" since that name already exists.

If I then want to run the script by name it will run the old one, with name "Script", when I really wanted to run the most recent, "Script 2".

 

And since I run the main script many times, it creates many versions of the "Script", when I just really want to keep updating it.

 

So far the most reliable option is to try to delete script with that name first before updating it:

try(dt << Delete Scripts( "Script" ));

dt << New Table Script( "Script", Show("Test"));

 

Also, Is there a way to get a pointer to table script and use it?

Something like:

 

script = dt << Get Table Script("Script");
script << Run Script();

or even get a pointer to the script when creating it (I checked, looks like it doesn't work, New Script message doesn't return anything)

script = dt << New Script("Script", Show("Test"));
script << Run Script();
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: How to update table script

Your suggestion to delete the script before recreating it, is the only method I am aware of to replace the script;

To move the script into a variable and then run the script, all  you have to do is:

script = dt << Get Table Script("Script");
script;
Jim

View solution in original post

Re: How to update table script

 In addition to @txnelson 's suggestion, you may want to rename the old "Script" to "Script_CurrentTime" instead of deleting it, then you can save the new script to "Script" without conflicts. This will create (old script) files you may not want to have captured, however, this would allow to track possible changes if required. 

/****NeverStopLearning****/

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: How to update table script

Your suggestion to delete the script before recreating it, is the only method I am aware of to replace the script;

To move the script into a variable and then run the script, all  you have to do is:

script = dt << Get Table Script("Script");
script;
Jim

Re: How to update table script

 In addition to @txnelson 's suggestion, you may want to rename the old "Script" to "Script_CurrentTime" instead of deleting it, then you can save the new script to "Script" without conflicts. This will create (old script) files you may not want to have captured, however, this would allow to track possible changes if required. 

/****NeverStopLearning****/