ACF Library

CountLines

Back to List

Description: Count number of lines in a text string

FileMaker Prototype:

Set Variable [$res; ACF_Run("CountLines"; string_txt)]

Category: UTILITY

Function source:

function CountLines ( string txt )
   if (txt == "") then
      return 0;
   end if
   txt = substitute ( txt, "\r\n", "\n");
   txt = substitute ( txt, "\r", "\n");
   txt = substitute ( txt, "¶", "\n");
   string matchedOnly = regex_replace("(?s)((?!\n).)*", txt, "");
   if (right(txt, 1) != "\n") then
      matchedOnly = matchedOnly + "\n";
   end if
   return length(matchedOnly); 
end

Back to List