Crystal Reports  

Preventing Infinite Loops (Crystal Syntax)

There is a safety mechanism to prevent report processing from hanging due to an infinite loop. Any one evaluation of a formula can have at most 100,000 loop condition evaluations per formula evaluation. For example:

Local NumberVar i := 1;
While i <= 200000 Do
(
   If i > {movie.STARS} Then
      Exit While;
   i := i + 1
);
20

If {movie.STARS} is greater than 100,000 then the loop condition (i <= 200000) will be evaluated more than the maximum number of times and an error message is displayed. Otherwise the loop is OK.

Note   The safety mechanism applies on a per formula base, not for each individual loop. For example:
Local NumberVar i := 1;
For i := 1 To 40000 Do
(
   Sin (i);
);
While i <= 70000 Do
(
   i := i + 1;
)

The above formula also triggers the safety mechanism since the 100,000 refers to the total number of loop condition evaluations in the formula and this formula will have 40001 + 70001 such evaluations.

See Also

For Loops | While Loops