[Solved] Calculating a array of values - VisualCron - Forum

Community forum

Danny van Oijen
2022-05-04T07:44:27Z
Hi all,

I have a question, i have a array of values:
0,00
1,34
9,36
etc.

I need to add them all up, can someone help me on how to do this?
The array can be long and can have negative values like -4,78
ErikC
2022-05-16T07:36:01Z
Hi,

The easy way is creating a job variable which holds the value of the additions and use a loop, eg 'additions'

You start with a set job variable task to set this job variable to value 0.
Then you create another set Job variable task using with the set value:
{MATH(Add|Double|NUMBER1|NUMBER2|#0.00)}

The 1st number should be the job variable and the second value should be the currentX value in the loop.

{MATH(Add|Double|{JOB(Active|Variable|additions)}|{LOOP(CurrentValueX)}|#0.00)}


The variable which is beying set is also the job variable.

So only two tasks here. The 2nd task must loop with the data from the array.

After the loop is done, the job variable holds the right number.

Regards
Erik
Uses Visualcron since 2006.
Michael Fjellström
2022-05-31T09:50:45Z
Scroll to Top