How to create a var that adds the values of another var in a loop?

I need some help here.
I want to make a counter of a specific set of actions.

I have a script that goes through a multi page website and stores a specific value for each page.

Lets say it’s 3 pages in total:
Page 1 contains 3 items.
Page 2 contains 4 items.
& Page 3 contains 1 item.

I have the script set up in a loop mode where it loops the “item” amount of times.
I would like to add the items from page 1,2, and 3 to be able to know how many items if acted on in total?

How do I solve this problem?

/Eric

It is unclear exactly what you are doing, but generally you use the Set Variable to Calculation action.

Set Variable “Total” to Calculation “Total + 1” (or “Total + Count”)

1 Like

Just append the value for each page to the same KM Variable, separated by a [SPACE], comma, or new line.

Then you should be able to adapt this Macro to achieve your objective:

1 Like

Thanks Peter. That totally works.
I tried this yesterday and it did not, probably due to a typo or something.

Much appreciated.

/E

Thanks JMichael.
I like your method of using an array.

Is there a way to push new values into an array via KM?

Just use a KM Action "Set Variable to Text":
%Variable%numberList%, 36, 55

This appends ", 36, 55" to the end of the KM Variable "numberList"

Remember that all KM Variables are actually strings, although we can make them work like numbers in calculations, and KM doesn't have real arrays.

1 Like

Thanks so much JMichaelTX
You guys are the best!