---
title: "For"
description: "Count from start to end and run the body each time."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/loops/for"
---
# For

> Count from start to end and run the body each time.

<block-meta block="Yes" channels="Any" folder="basic/loops" group="Loops" groupTo="/build/workflows/blocks/loops" icon="i-lucide-repeat" pipe="Value" scope="Any" tool="No" type="loop.for">



</block-meta>

**For** counts from **Start** toward **End** and runs the **callback** body once per step. After the last iteration, the main path continues and the pipe holds every value the body **return**ed.

Use [For Of](https://docs.vettero.com/build/workflows/blocks/loops/for-of) to walk a list and [For In](https://docs.vettero.com/build/workflows/blocks/loops/for-in) to walk an object. Use [Continue](https://docs.vettero.com/build/workflows/blocks/loops/continue) inside the body to skip an iteration, or [Break](https://docs.vettero.com/build/workflows/blocks/loops/break) to stop early.

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Start
      </strong>
    </td>
    
    <td>
      First counter value (number, or a context variable)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        End
      </strong>
    </td>
    
    <td>
      Stop bound (number, or a context variable). With a positive step, the counter runs <strong>
        while it is less than End
      </strong>
      
       (End is not included)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Step
      </strong>
      
       (optional)
    </td>
    
    <td>
      How much to add each time. Defaults to <code>
        1
      </code>
      
      . Must not be <code>
        0
      </code>
      
      . A negative step counts down <strong>
        while the counter is greater than End
      </strong>
    </td>
  </tr>
</tbody>
</table>

**Start**, **End**, and **Step** can be a fixed number or a path from this block’s context (`args.*`, `pipe.*`, named variables).

The **Callback** outlet must be connected to a [Lambda](https://docs.vettero.com/build/workflows/blocks/module/lambda) block. If it is not connected, the run fails.

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the loop finishes (main path, same scope)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Callback
      </strong>
    </td>
    
    <td>
      <strong>
        New callback scope
      </strong>
      
       for each iteration. Connect to <a href="https://docs.vettero.com/build/workflows/blocks/module/lambda">
        Lambda
      </a>
    </td>
  </tr>
</tbody>
</table>

Inside the body (after Lambda), use:

<table>
<thead>
  <tr>
    <th>
      Path
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        args.index
      </code>
    </td>
    
    <td>
      Zero-based iteration count (<code>
        0
      </code>
      
      , <code>
        1
      </code>
      
      , <code>
        2
      </code>
      
      , …)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        args.i
      </code>
    </td>
    
    <td>
      Current counter value (the <strong>
        Start
      </strong>
      
       / <strong>
        Step
      </strong>
      
       sequence)
    </td>
  </tr>
</tbody>
</table>

End the body with a **return**. That returns from this callback (this iteration), not from the whole workflow. The value is stored for this iteration. [Continue](https://docs.vettero.com/build/workflows/blocks/loops/continue) skips the rest of this pass. An unconnected **Out** ends the main path after the loop.

## Pipe schema

The next block on the main path reads this on the data pipe (`pipe.value`).

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Results
    </td>
    
    <td>
      list
    </td>
    
    <td>
      Values <strong>
        return
      </strong>
      
      ed from each iteration, in order. <a href="https://docs.vettero.com/build/workflows/blocks/loops/continue">
        Continue
      </a>
      
       skips collecting this pass; <a href="https://docs.vettero.com/build/workflows/blocks/loops/break">
        Break
      </a>
      
       stops further iterations; earlier returns stay in the list
    </td>
  </tr>
</tbody>
</table>

## Use case

- Repeat a step a known number of times (retry window, numbered pages, a range of days).
- Drive a counter (`args.i`) into a [condition](https://docs.vettero.com/build/workflows/blocks/condition), table write, or notification.
- Collect one result per pass, then use the list on the pipe after the loop.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
