422 users using DBSP now!
home -> documentation -> environment guide -> Conditional loops: The WHILE tag

The WHILE tag

The main purpose of the WHILE tag is to execute a block conditioned to the result of a Boolean expression. The general syntax of the while tag is described below:

<#WHILE EXPRESSIOn="anexpression">
  ...
<#/WHILE>

The WHILE tag repeats as long the expression given in the EXPRESSION property remains TRUE.

The expression is tested at the beginning of the loop, so if it is initially false, the loop code block will not be executed at all.

Note: In order to avoid infinite loops that could cause a server crash, the maximum iterations that could be executed are by default 6,500. If the code iterates more times than this value, an exception is raised.

Examples

Example 1. A simple WHILE

This example shows the general use of the WHILE Tag.

Source code
Test example


Example 2. A WHILE with a random condition.

In this example, the loop will continue while the condition holds.

Source code
Test example

Previous | Next