# Do..loop

The do..loop control statement is a script iteration construct which executes one or several statements until or while a logical condition is met.

Syntax:

Do [ ( while | until ) condition ] [statements]  
  
[exit do [ ( when | unless ) condition ] [statements]  
  
loop[ ( while | until ) condition ]

Information noteSince the do..loop statement is a control statement and as such is ended with either a semicolon or end-of-line, each of its three possible clauses (do, exit do and loop) must not cross a line boundary.

Arguments:

Do arguments

| Argument | Description |
| --- | --- |
| condition | A logical expression evaluating to True<br>or False. |
| statements | Any group of one or more QlikView script<br>statements. |
| while / until | The while or until<br>conditional clause must only appear once in any do..loop statement, i.e. either after do<br>or after loop. Each condition is interpreted only the first time it is encountered but is evaluated for<br>every time it encountered in the loop. |
| exit do | If an exit do clause is encountered<br>inside the loop, the execution of the script will be transferred to the<br>first statement after the loop<br>clause denoting the end of the loop. An exit<br>do clause can be made conditional by the optional use of a when or unless<br>suffix. |

Example:

`// LOAD  
 files file1.csv..file9.csv` `Set a=1;` `Do while 
 a<10` `LOAD * from 
 file$(a).csv;` `Let a=a+1;` `Loop`

## Learn more

* [Exit](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptControlStatements/Exit.htm)