I may be barking up the wrong tree, but it seems that the issue you are having is that you are using column references in your formulas, and what you need to do is to resolve those references as the formulas are created. Jarmo's example gives an example of doing just that, but it may be a bit confusing. Below is an attempt to explain the issue and the solution in a very simple example
// Here is a sample script, that creates a new data table
// with 2 columns, and what we want to do, is to simply
// put the value 1 into column c1, and a 2 into column c2
// In the first example, it is done by simply running a
// for() loop and taking the index variable, "i" and using it in
// the formula and squaring it's value.
Names Default To Here( 1 );
dt = New Table( "Example" );
dt<< add rows(1);
For( i = 1, i <= 2, i++,
dt << New Column( "c" || Char( i ),
formula( i^2 )
)
);
// When each column was created, it used the value of i at that
// time within the formula. Thus, for c1, the value of i was 1,
// and for c2 it was 4.
// So now, if we rerun the formulas, it will take the value of
// i at the time of rerunning each formula.
wait(5);
dt<<rerun formulas;
// After running the For() loop that was used to create the columns
// and to iterate i from 1 to 2, the loop is not stopped until i
// becomes greater than 2. Therefore, after running the loop,
// i has the value of 3, so when the formulas were run, i was
// equal to 3, and thus, all column values are set to 3.
// And now, what happens if the variable i is removed. This would
// be as if the data table had beed saved, and then reopned in a
// new session, and no variable named i has been created.
wait(5);
clear symbols(i);
dt<<rerun formulas;
// The point here, is that JMP does not resolve the variables in a
// formula when the formula is placed into the column. It is resolved
// then the formula is run.
// So to resolve this issue, we need to resolve the value of i as the
// formula is created.
Names Default To Here( 1 );
dt = New Table( "Example2" );
dt << add rows( 1 );
For( i = 1, i <= 2, i++,
Eval(
Eval Expr(
dt << New Column( "c" || Char( i ),
formula( Expr( i ) ^ 2 ) )
)
)
);
// Looking into the 2 formulas, c1 has the formula
// 1^2
// and variable c2 has the formula
// 2^2
// The value of the variable i was resolved before the
// actual formula was added to column c1 and c2
// Here is an old school way of doing the same thing, but in this
// example, the JSL statement to create the formula is built in
// a literal string, and then the JSL statement is run
Names Default To Here( 1 );
dt = New Table( "Example3" );
dt << add rows( 1 );
For( i = 1, i <= 2, i++,
Eval(
Parse(
"dt << New Column( \!"c" || Char( i ) || "\!",
formula( " || char( i ) || "^2 ) )"
)
)
I hope this is helpful
Jim