> For the complete documentation index, see [llms.txt](https://doc.sysdevmobile.com/kalipso/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.sysdevmobile.com/kalipso/6.0/documentation/actions/group-code-flow/while...end-while.md).

# While...End While

A while loop is a control flow statement that allows code to be executed repeatedly based on a given condition.

Action available for the following operating systems:

<figure><img src="https://1102213384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM6Wz3tBjSWbCweZ8NltT%2Fuploads%2FlMCpECAOJ3xRYg3Vgnqu%2F05_Supported_OS_android_ios_windows.png?alt=media&amp;token=4de523e1-6e2c-4501-806e-d0dd94dcd34f" alt="OS Supported: Android, iOS, Win"><figcaption></figcaption></figure>

### Parameters

* **Condition** *\<unquoted string> -* This parameter is the condition that is verified in iteration of while loop. This condition may be a complex expression with *AND* and *OR* operators like in the common programming languages.

### Usage

Consider the following database table "Products":

| **Code** | **Name**   | **Stock** |
| -------- | ---------- | --------- |
| 001      | Coca Cola  | 100       |
| 002      | Pepsi Cola | 200       |
| 003      | Pork Chops | 300       |

#### **Example 1**

```
Set Value(VAR(0),Numeric,0)
Set Value(VAR(1),Numeric,001)

While(VAR(0) <= 1)

SQL Statement(Delete; Products; FIELD(Products, Code)=VAR(1))
Set Value(VAR(1), Numeric, VAR(1)+1)
Set Value(VAR(0), Numeric, VAR(0)+1)

End While
```

**Result:**

| **Code** | **Name**   | **Stock** |
| -------- | ---------- | --------- |
| 003      | Pork Chops | 300       |

**Example 2**

```
Set Value(VAR(0),Numeric,0)
Set Value(VAR(1),Numeric,004)

While(VAR(0) < 3)

SQL Statement(Insert; Products; No; Yes; Code=VAR(1); Name="Product " + VAR(0); Stock=100)

Set Value(VAR(1), Numeric, VAR(1)+1)
Set Value(VAR(0), Numeric, VAR(0)+1)

End While
```

**Result:**

| **Code** | **Name**   | **Stock** |
| -------- | ---------- | --------- |
| 001      | Coca Cola  | 100       |
| 002      | Pepsi Cola | 200       |
| 003      | Pork Chops | 300       |
| 004      | Product 1  | 100       |
| 005      | Product 2  | 100       |
| 006      | Product 3  | 100       |
