I have a table (here simplified and called “TestBug.jsl” attached ) that is used to generate some random numbers and then make a calculation based on the table variable, let call this my “simulator table” as each time i re-calculate it this would be one simulation that i want to repeat many times.
then i have the following script to automate running the same simulation many times with different input and concatenate the resulting tables in a "result" table.
To test simply run the script with the TestBug.jsl as current data table,
Names Default To Here(1);
VarList={1,2,3,4};
New Namespace(
"MyNS"
);
MyNS:Simulator = Current Data Table();
MyNS:FinalT=MyNS:Simulator<<subset( Output Table( "final table" ),
Copy formula( 0 ),
All rows,
Selected columns only( 0 )
);
MyNS:FinalT<< Select All Rows;
MyNS:FinalT<< Delete Rows;
advancementWin=new window("Progress",
TBsizes= text box(),
);
for(is=1,is<=length(VarList),is++,
myVarVal=VarList[is];
TBsizes<<set text("Simulating:"|| char(myVarVal)||"(" || char(is)||"/" || char(length(VarList))||")");
MyNS:Simulator << Suppress Formula Eval( 1 ); //i need this as in the final version i make more changes and i want to avoid recalc of the random each change
MyNS:Simulator<<set table variable("myvar",myVarVal);
MyNS:Simulator << Suppress Formula Eval( 0 );
MyNS:Simulator<< Rerun Formulas();
MyNS:Final=MyNS:FinalT<<Concatenate(MyNS:Simulator, Append to first table);
);
advancementWin<<Closewindow();
Basically the script iterates and changes the table variables in the simulator table according to an input list and the resulting numbers concatenated in a “result table” (without carrying the formulas but just the numbers)
So what the script does initially is to create an empty result table that has the same columns as my "simulator", then iteratively changes the table variable in the “simulator” and concatenate it to the “result” table
However for some reason every time I change the value of the “simulator” variable, a new column is created as of the second iteration in the “result” table with the same name of the variable and filling it in with the value in a strange pattern (see picture)
Basically it adds the value of the variable at the previous iteration in the active columns for the new concatenated rows and the value of the final iteration to all the other rows…
This is just annoying for a few iterations but makes the whole process very slow/crashing for many iterations.
if i skip the "concatenate" or the "set table variable" the columns are not added.
I cannot understand what i am doing wrong.