Long ago I built a form that would add numerical values from several document variables and output that information to another document variable or obsterm. I cannot remember how I did it now, though.
Looking for some help from others with sounder minds than mine! 😀
I want to add up the values of several document variables and output into a 'totals' field.
Thanks!
This is how i do it -
{!fn AddNums(){
local total = 0
local i
for i = 1, i <= getnargs(), i = i + 1 do
total = total + val(getarg(i))
endfor
return total
}}
Then I can use it like this (with as many fields as you need) -
{DOCUMENT.TOTAL = AddNums(Document.thing1,document.thing2,obsnow("another value"))}
Remember to DECLARE the i variable as local otherwise it will be global and risk collision with other global variables named i. 😛
local i
Thank you guys, worked perfectly. Much appreciated!
Yeah yeah yeah, been there before. It makes troubleshooting fun 🙂
Updated my answer.