Loops
Learn about writing loops in Kognitos to repeat actions for multiple items.
Overview
A loop allows you to repeat actions for multiple items. In Kognitos, you can create a loop using process each x as follows
, where x
represents the item in a set. Loops are especially useful for batch processing, where you need to handle multiple items in a consistent manner.
General Syntax
To start a loop, use the following syntax:
By indenting the lines after process each {item} as follows
, Kognitos will know which instructions to follow for each item.
Indentation is Key
Remembering to indent when looping through objects in your automation is very important!
Example
Looping with a Counter
To track the number of iterations in a loop, you can use a counter. A counter is a numeric data element that starts at an initial value (usually zero) and increments with each iteration of the loop. This allows you to keep track of how many times the loop has executed.
Syntax
Initialize the counter before starting the loop. Within each iteration, increment the counter by 1.
Example
In this example, a loop is used to iterate through each page in a document. The counter is incremented after each page is processed.
Last updated
Was this helpful?