Skip to content

Toro Cloud Dev Center

Gloop iterate step icon

Iterate steps

The iterate step in Gloop is very similar to the for loop in Java and other programming languages. You simply give it an array of Gloop objects (or a Gloop input cursor) and it will iterate through them one by one, calling every Gloop step which is a child of it. They are especially useful when you want to perform mappings or transformations from one array to another.

Iterate steps rely on the Input Array property to determine what to iterate over. For every entry in the input array, the child steps of the iterate step will be invoked.

Iterate steps also have an Output Array property. This makes it easy to map or transform from one array of Gloop objects to another. By default, existing entries in the output array will be overwritten. Once the output array has less entries than the input, new entries are added to the output. If you prefer to always add the records to the output, you can change the Append property on the iterate step from false to true.

Iterate text

If your iterate step only has Input Array configured, its text in the service editor will appear as Iterate over <inputArrayName>. If it has both an input and output configured, it will appear as Iterate over <inputArray> → <outputArray>.

Iterate steps can also be configured to delay at the end of an iteration and close your Gloop cursors after finishing.

An iterate step will also introduce two variables to Gloop while it's being executed:

  • $gloopIndex - a zero-based counter of the loop
  • $gloopCount - a one-based counter of the loop

The array that the step is iterating over (and optionally writing to) will also appear as a single item in the Mapper view when you're in the context of the iterate step. Look closely at the Mapper view below to see how the iterate step changes what's available in the Mapper. You will notice the $gloopIndex and $gloopCount variables being added and the input array (which in this example, is called myArray) changes from an array to a single item (the array brackets badge on the bottom-right doesn't appear anymore).

Gloop iterate step context changes

Gloop iterate step context changes

Iterate over arrays like a ninja

If there is an array already in the Mapper view and you wish to iterate over it, you can trigger the content-assist feature by pressing in the Gloop step editor and then choosing the Iterate over array option. This will guide you to adding and pre-configuring the iterate step for you by asking for an Input Array and Output Array.

Creating an iterate step using Martini's content-assist

Creating an iterate step using Martini's content-assist