I only checked the version 2 of .jsl and it was quite close.
I have attached modified version.
I modified the loop part mostly. There is most likely way to manage without Eval(Parse()) with expressions but I went with this solution this time. You were using data from variable clean_DATA which stays the same for all rows. Also if you need to have formulas you will have to use Eval(Parse()) (or expressions?) to keep formulas working in the datatable. If no formulas are needed I would go with << Set Each Value instead of Formula.
For(i = 1, i <= ncols_to_add, i++, // the || operator joins two strings
Eval(Parse("dt << New Column(\!"c\!" || Char(i),Numeric, Continous,
Formula(Num(Substr(Regex(:data, \!"\D\!", \!"\!", GLOBALREPLACE ), "||char(i)||", 1 )));
)));")); // put 1 bit in each column
);
With << Set Each Value the for loop would look like this:
For(i = 1, i <= ncols_to_add, i++, // the || operator joins two strings
dt << New Column("c" || Char(i),Numeric, Continous,
<< Set Each Value(Num(Substr(Regex(:data, "\D", "", GLOBALREPLACE ), i, 1 )));
)
); // put 1 bit in each column
Edit:
Good post on using Eval Insert, Eval Expr, Parse and Substitute with formulas https://community.jmp.com/t5/JSL-Cookbook/Insert-one-expression-into-another-using-Eval-Insert-Eval-...
-Jarmo