Hi everyone,
I am relatively new to JMP and especially to scripting in JSL. I am looking for a way to apply a existing script to all currently open data tables (imported via multiple files import). Even though I researched through the abundance of community threads about this topic, I was not able to piece together a working solution.
Okay, so I have the following working JSL code (note: embedded in a workflow, if relevant):
// Specify the dataset and the suffix to search for in column headers
dt = Current Data Table();
// Define suffix of interest for replacement
targetSuffix = "TimeAbs";
// Get list of column names from the current data table
colNames = dt << Get Column Names( "string" );
// Loop through all column names and check if the target suffix is present
For( i = 1, i <= N Items( colNames ), i++,
If( Contains( colNames[i], targetSuffix ),
// If the target suffix is found, change the column header to "Date"
Column( dt, colNames[i] ) << Set Name( "Date" )
)
);
The current function of the workflow is the replacement of a column name in the currently open data table, however this name can vary between files, which is why I decided to only search for a fixed suffix.
I would now like to expand this script to apply to multiple data tables I have currently open. I have seen solutions on similar tasks based on For or For Each Loops and also with table scripts, but as I said I am quite new to JSL and failed to succeed as of yet.
Furthermore, this needs to be quite generic, because the file names and column names can vary quite drastically.
The ultimate goal is then to concatenate these table, but might be out of scope for a single question.
Thank you very much for any advice or ideas