How to use While Do Loop in Crystal Reports [Solved]

How to use While Do Loop in Crystal Reports

Crystal ReportThe following example searches for the first occurrence of a digit in an input string. If a digit is found, it returns its position, otherwise it returns -1. In this case, the input string is set explicitly to a string constant, but it could be set equal to a String type database field instead. For example, for the input String, “The 7 Dwarves”, the formula returns 5, which is the position of the digit 7.
Local StringVar inString := "The 7 Dwarves";
Local NumberVar strLen := Length (inString);
Local NumberVar result := -1;
Local NumberVar i := 1;
While i <= strLen And result = -1 Do
(
   Local StringVar c := inString [i];
   If NumericText (c) Then
      result := i;
   i := i + 1;
);
result

Credit: http://pic.dhe.ibm.com/infocenter/rsawshlp/v7r5m0/index.jsp?topic=%2Fcom.businessobjects.integration.eclipse.designer.doc%2Fhtml%2Ftopic501.html

Leave a Reply

Your email address will not be published. Required fields are marked *