|
Hi, I writing custom function in class. i want to use that custom class in crystal report formula but its not possible so i write custom function in crystal report same as that class function. class function working in windows application perfectly but in crystal report formula not working...
In class Code
public static string CropWholeWords(this string value, int length, HashSet<char> nonWordCharacters) { if (value == null) { throw new ArgumentNullException("value"); }
if (length < 0) { throw new ArgumentException("Negative values not allowed.", "length"); }
if (nonWordCharacters == null) { nonWordCharacters = DefaultNonWordCharacters; }
if (length >= value.Length) { return value; } int end = length;
for (int i = end; i > 0; i--) { if (value.IsWhitespace()) { break; }
if (nonWordCharacters.Contains(value) && (value.Length == i + 1 || value[i + 1] == ' ')) { break; } end--; }
if (end == 0) { end = length; }
return value.Substring(0, end); }
Crystal report Custom Function Code
function (stringVar ABC,numberVar leng,stringVar deli) ( stringVar Anss; numberVar end := leng; numbervar i; ( if(ABC = "") then ( Anss :=""; ) else if(leng < 0) then ( Anss :=""; ) else if(leng >= Length(ABC)) then ( Anss := ABC; ) );
for i := end to 1 do ( ( if (ABC = ' ' or ABC = 'n' or ABC = 't') then ( Exit for ) ); ( if (ABC = deli and (Length(ABC) = i + 1 or ABC[i + 1] = ' ')) then ( Exit for ) ); end := end - 1; );
( if(end = 0) then ( end := leng; ) );
Anss := mid(ABC,1,end); )
what mistake i did in crystal report formula. i m new to crystal report
|