Share via


While Loops

Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

A while loop enables you to repeatedly execute one or more statements, as long as a condition is true. The statement is executed from zero (not at all) to many times, depending on how many times the condition is met. This contrasts with a do...while loop. Here, the statement is always executed at least once before the condition is evaluated.

Syntax

while ( expression ) statement

statement can be replaced by a block of statements.

Example

   int no = 1;
    ;
    while (no <= conlen(cont))
    {
        print conpeek(cont,no);
        no = no + 1;
    } 

This traverses a container, cont, and prints out the contents of the container.

See also

Loops

Conditional Statements

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.