Formula doesn't work within a FOR loopHello,
working with a customer which aims to automate data gathering from various clinical study we used Action recorder to get the appropriate lines of script.
Now I'm simplifying the script using list and loops to make it generic for larger usage.
I was able to do it down to row 58. At rows 58-61 I try to reproduce what happens with rows 63-100 using a FOR loop and a formula as shown below:
For( i = 1, i <= N Items( colList ), i++,
Data Table( "Summary with Dose=0" ) <<
New Column( colList_Sum_3[i],
Numeric,
"Continuous",
Format( "Best", 12 ),
formula( colList_Sum_1[i] - colList_Sum_2[i] )
)
);
It creates the appropriate colums (based on a list) but not the formulas in each column.
I tried with Eval / Expr but I have to admit that I don't know how and when to use them.
Thanks for the help.
Emmanuel
Re: Formula doesn't work within a FOR loopHi Emmanuel,
You are only off by a bit. Try the script attached. It seems to work on your sample data. Corrections are commented as //Try this instead. Your original code is commented out.
Best,
Jason
Re: Formula doesn't work within a FOR loopHi Don, did you change anything in the script ? I guess you copy/paste the original one w/o any change or I missed it.
Re: Formula doesn't work within a FOR loopSorry Emmanuel,
Initially posted the original script. Reposted with the edited script.
Don
Re: Formula doesn't work within a FOR loopHi Jason,
in your edited script lines 69-76 does not return any calculation
For( i = 1, i <= N Items( colList ), i++,
Data Table( "Summary with Dose=0" ) << New Column( colList_Sum_3[i],
Numeric,
"Continuous",
Format( "Best", 12 ),
formula( Column( colList_Sum_1[i] ) - Column( colList_Sum_2[i] ) )
)
);
For clarification lines 69-76 (58-61 in the original script) aim to replace lines 78-115 (63-100 in the original script).
The rest of the script is OK it is on lines 69-76 (58-61 in the original script) that I'm stuck.
Re: Formula doesn't work within a FOR loopHi Don, I've been through the e-learning on scripting but I have hard time to understand Eval, Expr, NameExpr, ... by chance would you have any complementary course, documentation which could help ?
Re: Formula doesn't work within a FOR loopSorry about that, Emanuel. Perhaps not enough coffee. The syntax I intended is :As Column(). I did a check on final table and the formula seems to be differencing the columns as expected. There may be a better solution that leaves a formula in the new column that makes sense in the formula editor. Is it important to have a column formula or can you build a matrix and set values?
For( i = 1, i <= N Items( colList ), i++,
Data Table( "Summary with Dose=0" ) << New Column(
colList_Sum_3[i],
Numeric,
"Continuous",
Format( "Best", 12 ),
formula(:As Column(colList_Sum_1[i])-:As column(colList_Sum_2[i]))
)
);