# While Loop

> Repeat blocks while a condition is true.

- ID: `while_loop`
- Type: Loop
- Category: [Logic](https://inventor.bot/docs/reference/blocks/logic.md)

> Loops cannot exceed 5,000 iterations.

- Loop block: write `for item := range while_loop(Args{...}) { ... }` and read the current item's outputs from `item`. See loops.

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `value_1` | yes | The first value to compare. | e.g. `"hello"` |
| `condition` | yes | The comparison operator. | `"equals (=)"`, `"equals (case insensitive)"`, `"equals (numeric)"`, `"equals (float)"`, `"does not equal (!=)"`, `"does not equal (case insensitive)"`, `"greater than (>)"`, `"greater than (float)"`, `"less than (<)"`, `"less than (float)"`, `"greater or equal (>=)"`, `"greater or equal (float)"`, `"less or equal (<=)"`, `"less or equal (float)"`, `"contains"`, `"contains (case insensitive)"`, `"does not contain"`, `"does not contain (case insensitive)"`, `"is in the comma-separated list"`, `"is in the comma-separated list (case insensitive)"`, `"is not in the comma-separated list"`, `"is not in the comma-separated list (case insensitive)"`, `"starts with"`, `"starts with (case insensitive)"`, `"does not start with"`, `"does not start with (case insensitive)"`, `"ends with"`, `"ends with (case insensitive)"`, `"does not end with"`, `"does not end with (case insensitive)"`, `"is empty"`, `"is not empty"` |
| `value_2` | yes | The second value to compare. | e.g. `"5"` |
| `body` |  | Blocks to run each iteration. | blocks: `func() { ... }` |

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `current_iteration` | 1-based index of the current loop run. | e.g. `"1"` |
| `result` | Whether the condition evaluated to true or false. | e.g. `"true"` |

**Example**

```go
for loop := range while_loop(Args{
	value_1:   "hello",
	condition: "less than (<)",
	value_2:   5,
}) {
	send_text_message(Args{channel_id: trigger.channel_id, message_content: "Result: " + loop.result})
}
```