Since this old thread is current again, let's give its subject some fresh consideration.
Here's a newer way to count occurrences of a substring like "APPROVAL NO"
Code: Select all
function countSubstrings pString, pSubstring
set the lineDelimiter to pSubstring
return number of lines in pString - 1
end countSubstrings
Code: Select all
function blocksWithSubstring pString, pBlockDelimiter, pSubstring
set the lineDelimiter to pBlockDelimiter
filter pString with "*" & pSubstring & "*"
-- now replace the block delimiters that were just filtered out:
repeat for each line tLine in pString
get it & pBlockDelimiter & tLine & cr
end repeat
return it
end blocksWithSubstring
-- Dick