PreviousNext
Help > PROGRAM CONTROL STRUCTURES > Loop
Loop

Unlike other programming languages, Rittle offers only a single loop structure. It is however flexible enough to cover all needs.

The format it:

while [condition1];         ’ Repeating the loop while this condition is true

 

    ……. body of the loop structure …….

 

until [condition2];           ’ Repeating the loop until this condition become true

 

The loop can have none, one, or two conditions. Note again the closing semi-colons after the conditions. These semi-colons are required even if there is no conditional expression.

Condition1 gets checked before the body of the loop. If true, the loop continues with the iteration. If false, the loop ends and continues with the code after “until”.

Condition2 gets checked after the body of the loop. If false, the loop closes and returns back to the “while” (and to check again condition1). If condition2 is true, the loop ends, and the execution continues after it.

If both conditions are missing, the loop becomes an infinite loop, and can be stopped only with an “exitloop” command.

An example of a loop performing 100 iterations:

var small a=0;

while a<100;

    ……. Something to do here …….

    a=a+1;

until;

 

The popular “for()” programming structure in other languages can be easily also expressed in Rittle. An example below is for a loop with 1000 iterations:

 

var small a=1000; while(a--);

    ……. Something to do here …….

until;