Create a new Row() column only if it does not existI need to script the creation of a new column with the row number only.
As this is part of an add-in, this column may exist already or the table may have the same column name by chance.
This column can be hidden to the user but will be later used for virtual linking tables.
What would be the best approach? Maybe to add a property to make this column unique?
ScriptingRe: Create a new Row() column only if it does not existHere is how I would do it. It is making the assumption if the column already exists, that the column needs to be deleted and a new one put in it's place.
names default to here(1);
dt=current data table();
if( try(column(dt,"_%_Row_%_") << get name, "" ) == "_%_Row_%_",
dt << delete column (:name("_%_Row_%_"))
);
dt << new column( "_%_Row_%_", formula( Row() ));
dt:Name("_%_Row_%_") << delete formula << hide;