REPEAT - UNTIL Loop

REPEAT - UNTIL Loop or Statement In Microsoft Dynamics NAV C/AL

Definition

REPEAT - UNTIL Loop is a repetative loop, is used for programmes having one or more statements to be executed until some condition.

Syntax OF REPEAT - UNTIL Loop

---------------------------------------------------

REPEAT Satements UNTIL Boolean Expression

---------------------------------------------------

This works in a manner like that it will work the statements until the Boolean Expression is true. The difference Between WHILE-DO loop is that the REPEAT - UNTIL Loop will execute atleast one time and then only it will check the Boolean expression true or false. But in the case of WHILE-DO loop only execute the code when a particular condition is true.

For Example:

=======================================

REPEAT

i :=  i + 1;

Total Sales := Total Sales + Sales[i];

UNTIL Sales[i]=0;

=======================================

The abow example works in a manner like that it will execute the statement once after that check the Boolean expression Sales[i]=0 or not if the condition is true then reapeat the statement otherwise it will exit from the loop and execute the statement immediatly after that.

Related Posts with Thumbnails