---
title: "while — While loop"
description: "iXML command while: While loop."
canonical_url: "https://www.zeyos.com/ixml/ref/while"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ref/while.md"
section: "ixml-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/ixmldoc.xml"
source_sha256: "a23f04e6a98628ca3c273c3b8dd2c33c034cfda3e0f00478d8793074fd2f70dd"
---

# while — While loop

The WHILE construct is a control flow structure that allows code to be executed repeatedly based on a condition. It can be thought of as a repeating IF construct that is being re-evaluated before each loop iteration.

While the condition is true, the embedded code is executed. Otherwise, the execution continues outside the loop.

### Attributes
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| value1 | string |  | Value to compare from |
| value2 | string\|regexp |  | Value to compare to |
| func | string | = | Comparison function |

#### Possible values
Possible values for `func`:
- = — Equals
- =* — Equals, case-insensitive
- != — Not equals
- <> — Not equals
- !=* — Not equals, case-insensitive
- <>* — Not equals, case-insensitive
- < — Less than
- <= — Less than or equal to
- > — Greater than
- >= — Greater than or equal to
- _ — Contains
- _* — Contains, case-insensitive
- !_ — Not contains
- !_* — Not contains, case-insensitive
- ^ — Starts with
- ^* — Starts with, case-insensitive
- !^ — Not starts with
- !^* — Not starts with, case-insensitive
- $ — Ends with
- $* — Ends with, case-insensitive
- !$ — Not ends with
- !$* — Not ends with, case-insensitive
- ~ — Matches regular expression
- !~ — Not matches regular expression


### Children
- else (occurrence: single) — Elsewise execution

### Parents
- (not restricted in the reference)

### Result
- (none documented)

### Examples

```xml
<set var="count">0</set>

<while value1="$count" func="&lt;" value2="10">
	<output>$count</output>
	<math:inc var="count"/>
</while>

<!-- 0123456789 -->
```

```xml
<set var="count">0</set>

<while>
	<output>$count</output>
	<math:inc var="count"/>

	<if value1="$count" func="=" value2="10">
		<break/>
	</if>
</while>

<!-- 0123456789 -->
```

```xml
<set var="count">0</set>

<while value1="$count" func="&lt;" value2="9">
	<math:inc var="count"/>

	<if value1="$count" func="=" value2="5">
		<next/>
	</if>

	<output>$count</output>
</while>

<!-- 12346789 -->
```
