Loops

Looping in Midio is as simple as connecting nodes in a loop. This can however easily create infinite loops if we don’t branch out of the loop at some point.

There are two main helper functions in Midio that makes it easy to prevent infinite loops:

  • For - used to loop a given number of times

  • For Each - used to loop once per item in a list

For

The For node allows you to repeat a sequence of nodes a set number of times, determined by the iterations input.

  1. Start the loop by triggering the reset input.

  2. For will then activate the on count output trigger once per iteration, up to the specified number of times.

  3. To continue looping, connect on count to the next node(s) in your sequence, and then back to the count input of For. This advances to the next iteration.

  4. Once all iterations are complete, the done output trigger is activated.

For Each

The For Each node allows you to loop through a list of items, executing a sequence of actions for each item in the list. Unlike a standard For loop that runs a fixed number of times, For Each automatically iterates over every element in a list, passing along both the current item and its index in the list.

  1. Trigger the loop by activating the reset input.

  2. For each item in the list, For Each activates the on item output trigger.

  3. The item output provides the value of the current element, while the index output gives its position in the list.

  4. Once all items have been processed, the done output trigger is activated.

Last updated

Was this helpful?