Here are the loop explanations from the Crystal help file:
The 2 different types of While loops
Type of While Loop
While ... Do
The While ... Do loop evaluates the condition, and if the condition is true, then it evaluates the expression following the Do.
When it has finished doing this, it evaluates the condition again and if the condition is true, it evaluates the expression following the Do again. It continues repeating this process until the condition is false.
While condition Do
expression
Do ... While
The Do ... While loop evaluates the expression once no matter what.
It then evaluates the condition, and if the condition is true, evaluates the expression again. This process continues until the condition is false.
Do
expression
While condition
Note:
The While loops support an Exit While statement to immediately jump out of the loop. Its use is analogous to the use of Exit For in For loops.
As with the For loop, the While loop when considered as an expression always returns the Boolean value True.
The syntax of the For loop through examples
Suppose you want to reverse the {Customer.Customer Name} string. For example, "City Cyclists" becomes "stsilcyC ytiC".
//Reverse a string version 1
Local StringVar str := "";
Local NumberVar strLen :=
Length ({Customer.Customer Name});
Local NumberVar i;
For i := 1 To strLen Do
(
Local NumberVar charPos := strLen - i + 1;
str := str + {Customer.Customer Name}[charPos]
);
str