Using Loops to Control a Bot
Using loops in Automation 360 allows for developers to control how many times, and under what conditions, actions are run in a repetitive basis. Mastering loops means having full control over your bot’s actions, and making sure that the bot can dynamically handle a single operation or multiple operations in a single bot run.
Loops are one of the most powerful constructs in bot building. Loops are instructions that repeat-containing actions for a specific number of times or until a specified condition has been satisfied. In a loop, the loop checks for the completed number of specified iterations or the satisfaction of a condition – if that condition is not yet satisfied or the number of iterations is not yet satisfied, then the operations within the loop are executed. The same conditions are checked for again and again until the condition(s) has been satisfied, at which point the logic inside the loop is no longer executed. Each time the condition is checked for satisfaction is called an iteration of the loop.
To Do
Take a look at the documentation on the Loop package.
Technically there are only 3 actions: Loop, Continue, and Break.
- Loop is the action developers will most commonly use to customize the repetitions of their bots. Technically there are really 2 subtypes of this action – While loops and Iterator loops – each with a number of customizations that could be made of each.
- Continue enables the loop to immediately move on to the next iteration of the loop – typically used in conjunction with a conditional statement that identified no further action is required for this iteration.
- Break enables the loop to immediately be terminated – meaning that no further iterations would execute. This is typically used when iterating through a list to find the first match – after which no further matches need to be fetched.
Summary
Loops can be very powerful when used correctly in bot builds especially when actions need to be taken a variable number of times. If you find yourself automating a process that “sometimes needs to run once, but sometimes needs to run multiple times based on “you’ll know that its going to be a good opportunity to build the bot in a dynamic way in order to handle such variability using loops.