Syntax for Retrieving Data from a List Inside For a Loop in a Formula Editor Using Crystal Reports 8.5

What is the syntax for extracting data from a list inside a for loop in a formula editor? I wrote something like this, but it shows an error. Can anyone fix this?

Local NumberVar i; Local NumberVar intCount := Count({FOODMASTER.FOOD_SORT}); For i := 1 to intCount Do ( If (i = 1) Then {TMPMONTHLYDETAIL.TMP_QTY}[i]; Else If (i > 1) Then Exit For; i := i + 1; ); 

Where {FOODMASTER.FOOD_SORT} is an int data type and {TMPMONTHLYDETAIL.TMP_QTY} is decimal.

+4
source share
1 answer

This code doesn't really make much logical sense, let alone syntax. What exactly are you trying to achieve? You may need to rethink the situation a bit, but here are a few things to get you started:

  • You do not need to manually increase i , since for-loop does this for you with a default step of 1.
  • You say that {TMPMONTHLYDETAIL.TMP_QTY} is a number, not an array or a string, so you cannot reference it through {TMPMONTHLYDETAIL.TMP_QTY}[i] .
  • Your for-loop doesn't actually do anything useful. At the beginning of the loop, you do i:=1 , and then immediately check if there is i=1 , otherwise you just exit the loop. The entire cycle can be deleted and reduced to return {TMPMONTHLYDETAIL.TMP_QTY}[1] .
0
source

All Articles