Skip to content

Gloop Iterate Icon

Iterate

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 an input array configured, its text in the Gloop 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).

Coder Studio Gloop Iterate Context Changes

Iteration 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 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 and Output array.

Coder Studio Interation Ninja