Hi all,
I’m running a JSL script that performs Update/Join operations between calculation tables and filtered data tables. I noticed the following behavior:
-
When the script runs multiple times, JMP automatically renames duplicate columns to avoid name collisions, e.g.,
-
Even if I close the tables from the panel, the variables (column objects) still exist in memory, so re-running the script creates additional duplicate columns.
-
My current workaround is to exit JMP and restart before running the script to prevent duplicate columns.
Questions for the community:
-
Are there best practices for repeated Update or Join operations that avoid generating duplicate columns?
-
Is there a recommended way to “clean up” tables/variables after a script run so subsequent runs do not create duplicates?
-
Are there functions or JSL patterns to safely rename or overwrite columns without generating extra copies?
Any suggestions or strategies would be greatly appreciated!
I also tried this code to handle them dynamically but didn't worlk
RenameColumn = Function({dt, oldNamePattern, newName},
colList = dt << Get Column Names; // returns a column list object
n = N Items(colList); // number of columns
For(i = 1, i <= n, i++,
c = colList[i]; // get the column name as string
If(Contains(c, oldNamePattern),
Column(dt, c) << Set Name(newName);
Break(); // optional: stop after first match
);
);
);