Below is a script that if you have setup your data table correctly, should show you one way to solve the problem
Names Default To Here( 1 );
// Create a sample table
dt = New Table( "Example",
Add Rows( 3 ),
New Column( "ID", Character, "Nominal", Set Values( {"#1", "#2", "#3"} ) ),
New Column( "X_loc", Set Values( [2, 3, 4] ) ),
New Column( "Y_loc", Set Values( [2, 2, 4] ) ),
New Column( "Z_Surce_Column_A", Set Values( [4, 5, -4] ), Set Display Width( 118 ) ),
New Column( "Z_Source_Column_B", Set Values( [-4, -10, 1] ), Set Display Width( 133 ) )
);
// Wait 5 seconds so you can see the beginning table
wait(5);
// Loop across the columns to find the ones to change
For( i = 1, i <= N Cols( dt ), i++,
If(
Contains( Column( dt, i ) << get name, "Z" ) & Contains( Column( dt, i ) << get name, "A" ),
Column( dt, i ) << set name( "Z_A" ),
Contains( Column( dt, i ) << get name, "Z" ) & Contains( Column( dt, i ) << get name, "B" ),
Column( dt, i ) << set name( "Z_B" )
)
);
// Create the new column and move it to where it is to be located
dt << New Column("The New Column", formula(:X_loc/1000));
dt << go to(:The New Column );
dt << Move Selected Columns(After(:Y_loc));
You need to study the script and learn how it works.