Skip to main content
Version: 6.1

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:

OS Supported: Android, iOS, Win

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":

CodeNameStock
001Coca Cola100
002Pepsi Cola200
003Pork Chops300

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:

CodeNameStock
003Pork Chops300

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:

CodeNameStock
001Coca Cola100
002Pepsi Cola200
003Pork Chops300
004Product 1100
005Product 2100
006Product 3100