All,
Need some help in the following case.
I have a name of a column in a string format.
I need to create a new column with formula based on the old one. I do it like so:
oldCol = "OldColumn";
Eval( Eval Expr( dt << New Column( "NewColumn", formula( As Column( Expr( oldCol ) ) ) ) ) );
Then later in the script I need to rename the old column. I do it like this:
Column(oldCol) << Set Name("NewOldColumn");
The problem now is that since I have the New Column's formula in the form of:
As Column("OldColumn")
it does not update when OldColumn changes name.
I would like to have it in the form of
:OldColumn
but I don't know how to do that.
So, the question is: How do I need to modify expression:
Eval( Eval Expr( dt << New Column( "NewColumn", formula( As Column( Expr( oldCol ) ) ) ) ) );
so that it produces formula in the form of :OldColumn, and not in the form of As Column("OldColumn")?
Here is the full script to play with:
dt = New Table( "TestColumnsReferences",
Add Rows( 3 ),
New Column( "OldColumn", Character, "Nominal", Set Values( {"a", "b", "c"} ) )
);
oldCol = (dt << Get Column Names(string))[1];
//oldCol = "OldColumn";
Eval( Eval Expr( dt << New Column( "NewColumn", formula( As Column( Expr( oldCol ) ) ) ) ) );
Column(oldCol) << Set Name("NewOldColumn");
Thanks, M.