I have a set of scripts that I copy to new data tables. To make sure that when I run the table script it acts on the data table it belongs to I have to edit all of the scripts to point to the right data table (dt = Data Table("this one")). Is there a generic way to reference the parent data table, similar to dt = Current Data Table(), but more like dt = Parent Data Table()?
At the point when you run the table script, the table that it is associated with is the current data table so you should be able to use dt = CurrentDataTable().
If the script is open for editing, running the script from the editor will grab whichever data table is current using dt = Current Data Table(). The only way to guarantee that the script will point at the right table is by being explicit about the table the script should act on (which is what JMP teaches in the Intro to Scripting class as a best practice), so I'm looking for a way to do that generically so I don't have to constantly update the scripts everytime the data table name changes.
In the attached photo, the table script belongs to Data Table("this one") and Data Table("that one") is the Current Data Table(). If "when you run the table script, the table that it is associated with is the current data table" then the result of the scipt should be "this one" not "that one"
You should be able to create an "OnOpen" table script that when you open the table, it creates a globle variable that contains the current data table that you are working on. Then in the subsequent scripts, you reference that global variable. Just moving from one table to another would not change that global variable. It would only change when another one of your taqbles that has an "OnOpen" table script that changes the global variable is opened.
Thanks Jim. I could probably also handle it with a table variable. Can those be hidden? I already have quite a few, and I'd like to limit them.
not hidden, but you can group them, which takes all of the grouped scripts and places them in a expandable single label
There is another, more complex way to approach this. Rather than doing a copy/paste for your table scripts, you could write a script that adds the various table scripts to the new table, and within that script, it could generate the code for each of the scripts that would point to the data table the scripts are in.
There are no labels assigned to this post.