For Loop
Loops in eMOBIQ allow you to repeat actions until specific conditions are met. The 'forLoop' block is a simple way to create loops in visual logic.
Understanding Loops:
Loops in eMOBIQ are a way to repeat actions automatically until a particular requirement is fulfilled. This allows developers to efficiently perform repetitive tasks, like going through a collection of elements or executing a specific piece of code multiple times.
The 'forLoop' Loop:
The 'forLoop' block is a fundamental component in eMOBIQ's visual logic. It represents a basic form of a loop that executes a set of instructions for a set number of times, based on the range of values defined by the user. This block has three essential parameters:
'start': Represents the starting value of the loop, acting as the initial point for iterations.
'end': Defines the end value of the loop, determining when the loop stops executing.
'callback': Requires a callback function as an argument, containing the logic to be executed during each iteration of the loop.
Implementing forLoops in Visual Logic:
To create a loop using the 'forLoop' block in eMOBIQ's visual logic, follow these steps:
Drag and drop the 'forLoop' logic block onto the visual logic canvas.
Set the 'start' and 'end' parameters to define the range of iterations.
Create the loop's logic by adding and connecting other logic blocks within the 'Yes' callback. This represents the body of the loop that will be executed repeatedly.
Ensure that the logic inside the 'callback' section utilizes the loop variable (i.e., the loop index) to perform different actions during each iteration. The loop index value is accessible using the 'input' parameter in the child logic block.
Loop Visualization
In this example, by inserting the 'console' block as the 'Yes' callback of the 'forLoop' block, it becomes the body of the for loop and thus will be executed at every loop iteration. The 'reload' block is subsequently placed on the same level as the 'forLoop' block, so it will run only after the 'forLoop' has finished its execution.
Last updated