Titan



do


The keyword defines a loop which is executed as long as the loop condition holds. The loop condition shall be checked at the end of each new loop iteration. If the loop condition does not hold, then the loop is exited and execution shall continue with the statement, which immediately follows the loop.

Related keyword:


do {  statement_block } while ( condition);


Example 1:

var integer ii := 3; 
do {ii:= ii+2 } while (ii<=10) 

The loop variable ii is declared in the first line and it is given the initial value 3. In the second line, a loop is defined.  In the statement block the index variable is increased by 2 every time the loop is executed. The loop execution terminates when the index value will have a value greater than 10. The loop will be executed 6 times.



BNF definition of do