Examples of WHILE Statements

In the following example, as long as INDX is less than or equal to MAXVAL, the value of X is incremented by the value A[INDX].

WHILE INDX LEQ MAXVAL DO
   X := *+A[INDX];

In the following example, as long as J is less than LIMIT, the compound statement is executed. Contiguous elements of array SU are assigned the values of the elements of array SVALUES with the same indexes.

WHILE J LSS LIMIT DO
   BEGIN
   SU[J] := SVALUES[J];
   J := *+1;
   END;