# For Each Loop

## Overview

![The For Each Loop Node.](/files/uX2ydD21g13ieZ7Rn07j)

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**](/incari-studio/2023.1/toolbox/overview.md#scopes): **Project**, **Scene**, **Function**, **Prefab**.

## Attributes

![The For Each Loop Node Attributes.](/files/Lf4ZcttcdUMSIbjNkuKF)

| 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**](/incari-studio/2023.1/toolbox/flow-control/forloop.md)

## External Links

* [*For each loop explanation*](https://en.wikipedia.org/wiki/Foreach_loop#:~:text=For%20each%20loops%20are%20almost%20always%20used%20to,flow%20statement%20for%20traversing%20items%20in%20a%20collection.) on Wikipedia.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.incari.com/incari-studio/2023.1/toolbox/flow-control/foreachloop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
