The loop keyword executes a series of sequential statements multiple times.

 

A loop statement can include either:

 

(1) a "while" iteration scheme,

(2) a "for" iteration scheme, or

(3) no iteration scheme.

 

A loop statement using a "while" iteration scheme includes—in this order—the following:

 

(a) an optional loop label,

(b) the reserved word "while", followed by the condition which controls whether the series of sequential statements within the loop is executed, followed by the reserved word "loop",

(c) the series of sequential statements to be executed if the condition in (b) evaluates to be True,

(d) the reserved words "end loop", followed by an optional loop label (which, if used, must be the same as the loop label in (a).

 

Example

    while (I < DBUS’length) loop

      ...

      I := I + 1;

    end loop;

 

A loop statement using a "for" iteration scheme includes—in this order—the following:

 

(a) an optional loop label,

(b) the reserved word "for", followed by a parameter specification for the "for", followed by the reserved word "loop",

(c) the series of sequential statements to be executed for the instances defined in the parameter specification in (b),

(d) the reserved words "end loop", followed by an optional loop label, which, if used, must be the same as the loop label in (a).

 

Example

    for I in 0 to DBUS’length - 1 loop

      ...

    end loop;

 

A loop statement with no iteration scheme includes—in this order—the following:

 

(a) an optional loop label,

(b) the reserved word "loop",

(c) the series of sequential statements to be executed,

(d) the reserved words "end loop", followed by an optional loop label, which, if used, must be the same as the loop label in (a).

 

A loop statement with no iteration scheme continues to execute until some action causes execution to cease.  This could be done using an "exit" statement, a "next" statement, or a "return" statement within the loop.

 

Example

    loop

      exit when I = DBUS’length;

      I := I + 1;

    end loop;

 

LRM

    8.9