# For Each Loop

## Overview

![The For Each Loop Node.](https://2561100106-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ff6JZovzOqBctA4C1o76u%2Fuploads%2Fgit-blob-c253f9fc875a1566b7d20652a0fa660811929af4%2Fforeachloopupdatedimage.png?alt=media)

The **For Each Loop Node** triggers an iterative process that steps through the provided **Array** input. The output can then, for example, be printed to the **Console** or affect the next **Node** in the **Logic Branch**.

[**Scope**](https://docs.incari.com/incari-studio/2023.2/overview#scopes): **Project**, **Scene**, **Function**, **Prefab**.

## Attributes

![The For Each Loop Node Attributes.](https://2561100106-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ff6JZovzOqBctA4C1o76u%2Fuploads%2Fgit-blob-ffcea6566778c451d372c4cf2ca5303b4f5b9a71%2Fforeachloopattributes.png?alt=media)

| Attribute    | Type          | Description                                                                                                           |
| ------------ | ------------- | --------------------------------------------------------------------------------------------------------------------- |
| `Data Type`  | **Drop-down** | The **Variable Type** that populates the **Array**.                                                                   |
| `Error Mode` | **Drop-down** | The action that takes place if there is an **Error**. The user can choose from **Abort**, **Break**, or **Continue**. |

## Inputs

| Input             | Type      | Description                                                           |
| ----------------- | --------- | --------------------------------------------------------------------- |
| *Pulse Input* (►) | **Pulse** | A standard **Input Pulse**, to trigger the execution of the **Node**. |
| `Array`           | **Array** | The referenced **Array**.                                             |

## Outputs

| Output             | Type              | Description                                                                                                                            |
| ------------------ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| *Pulse Output* (►) | **Pulse**         | A standard **Output Pulse**, to move onto the next **Node** along the **Logic Branch**, once this **Node** has finished its execution. |
| `Value`            | **Variable Type** | The value of a **Variable** in the **Array**, whose type matches the type of the **Array**.                                            |
| `Index`            | **Variable Type** | The index of a **Variable** in the **Array**, whose type matches the type of the **Array**.                                            |
| `Array`            | **Array**         | The referenced **Array**.                                                                                                              |
| `OnTypeError` (►)  | **Pulse**         | A **Pulse** that flows to some action that can alert the user of a **Type Error**, such as printing a message to the **Console**.      |
| `OnEnd` (►)        | **Pulse**         | A **Pulse** that flows to some action that can alert the user that the loop has ended, such as printing a message to the **Console**.  |

## See Also

* [**For Loop**](https://docs.incari.com/incari-studio/2023.2/toolbox/flow-control/forloop)

## External Links

* [*For each loop explanation*](https://en.wikipedia.org/wiki/Foreach_loop) on Wikipedia.
