Counting Chars by ASCI Values

Ken Ray kray at sonsothunder.com
Tue Feb 28 23:33:02 EST 2006


> function CountChars pString,pChar
>   replace space with null in pString
>   replace pChar with space in pString
>   return ((the number of words of pString)-1)
> end CountChars

Whoops! Forgot to make sure it counts right if the first or last char is the
match char:

function CountChars pString,pChar
  replace space with null in pString
  replace pChar with space in pString
  put ((the number of words of pString)-1) into tNumChars
  if char 1 of pString = space then add 1 to tNumChars
  if char -1 of pString = space then add 1 to tNumChars
  return tNumChars
end CountChars


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list