Craige,
I used your suggestion of using a print statement and found that it never got to the line I thought was the problem.
newcol = dt << new column("Temp", numeric, formula(eval(evalexpr(Fexpr))));
The problem was at this line.
nnm1 = Col Number(colcol);
So I changed it to this and that worked.
nnm1 = dtTOSA << Col Number(colcol);
I found that I also needed to remind JMP again what the current table was later in the code and I had to use {} in Delete Columns before it worked. For some reason JMP doesn't care if those curly brackets are there if run from a script window.
The code snippet is now this. By the way this is a snippet of a longer code that also creates this and another table.
AllCols = dtTOSA << Get Column Names();
AllColNames = dtTOSA << Get Column Names(string);
currentDatatable(dtTOSA);
for(i=3, i<=n items(AllCols), i++,
colcol = AllCols[i];
cname = AllColNames[i];
nnm1 = dtTOSA << Col Number(colcol);
Fstr = "num(:\!""||cname||"\!"n)";
Fexpr = parse(Fstr);
newcol = dtTOSA << new column("Temp", numeric, set formula(eval(evalexpr(Fexpr))));
nnm2 = dtTOSA << Col Number(newcol);
if(nnm2 == nnm1,
currentDatatable(dtTOSA);
newcol << delete formula();
dtTOSA << Delete Columns({colcol});
wait(0);
newcol << set name(cname), //else
dtTOSA << Delete Columns({newcol});
);
);
However, now there is a different problem. Even though, I delete the old column before renaming the new column, JMP puts an unwanted 2 after the column name! Again it does not do this running from a script window. I tried including a wait(0) statement but that didn't help.
How can this be fixed?