The WHILE tag is used to repeat n times a block of HTML code based on a Boolean condition. This condition is evaluated and while the condition remains true the statement block of code is interpreted and its result inserted. Be careful when using this tag, because you could create infinite loops. However, the DBSP Engine will break the loop after bypassing the MAXITERATIONS value.
Specify in anexpression a Boolean expression (the final result must be true or false; in other case, the DBSP Engine will raise an exception). If you want to know more about the kind of expressions you can use, see arithmetic expressions.
MAXITERATIONS
Specify in maxiterations the maximum number of cycles that the while could execute before breaking the loop. This property is used in order to avoid infinite loops on the server. If this property is not specified, the default value (6500) is used.
The WHILE tag is one of the most important logic blocks in many programming languages, including DBSP. It allows you to conditionally insert code fragments. WHILE tags can be nested indefinitely within other WHILE tags, which provides you with complete flexibility for conditionally insertion and execution anywhere on your DBSP page.
Examples
Example 1. Simple WHILE.
Suppose that you have two variables, one bigger than the other. The first one increments its value until both values are equal.
When this happens, the condition is satisfied and loop terminates.
Due to the variety of Web browsers and applications available today, it's a necessity to have a subset of colors that could be reproduced faithfully regardless which hardware is used. This subset of colors is named "Safe colors" and in internet applications they are called "Safe web colors".
This example shows how to produce this palette using DBSP. Each channel of color (RGB) is limited to take one of these values: (00, 33, 66, 99, CC, FF). The table below is the result of the 6^3 possible colors. Place the mouse over any item to see the corresponding HEX color value.