I wrote the script using JMP 15, which properly evaluated the
Column( i ) << get name.
However, after your response, I went back and found that JMP 14 and earlier require an Eval() to force JMP to get the results of the << get name
Eval( Column( i ) << get name )
The code below works for JMP 15 and the previous versions
Names Default To Here( 1 );
dt = New Table( "Example",
Add Rows( 12 ),
New Column( "Column 1", Character, "Nominal" ),
New Column( "CH0 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH0 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH1 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH10 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 3 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 R State 4 Delta Amp @ Freq", Numeric, "Continuous", Format( "Best", 10 ) ),
New Column( "CH11 T State 1 @ Freq", Numeric, "Continuous", Format( "Best", 10 ) )
);
Wait( 5 ); // Wait 5 seconds so one can see the original example table
// If a column name starts with "CH" adjust the name
For( i = 2, i <= N Cols( dt ), i++,
If( Substr( Column( i ) << get name, 1, 2 ) == "CH",
Column( i ) << set property( "Original Name", Eval( Column( i ) << get name ) );
tempName = Substr( Column( i ) << get name, 3 );
number = Word( 1, tempName, " " );
tempName = Substr( tempName, Length( number ) + 2 );
number = Substr( "00", Length( number ) ) || number;
tempName = "CH" || number || " " || tempName;
Column( i ) << set name( tempName );
)
);
// Reorder the table names
dt << reorder by name;
// Replace the column names with the original names
For( i = 1, i <= N Cols( dt ), i++,
If( Is Empty( Column( i ) << get property( "Original Name" ) ) == 0,
Column( i ) << set name( Column( i ) << get property( "Original Name" ) );
Column( i ) << delete property( "Original Name" );
)
);
Jim