Counting Chars by ASCI Values

Jonathan Lynch jonathandlynch at gmail.com
Tue Feb 28 16:41:43 EST 2006


You know, you can use the numtochar and chartonum functions to go between
ascii/ansi numbers and the equivalent character.

like this

function NumCharsInString pAsciiChar pString
  put numtochar(pString) into tChar
  put 0 into tCount
  repeat for each char tCharToCheck in pString
    if tChar = tCharToCheck then add 1 to tCount
  end repeat
  return tCount
end NumCharsInString


You would use this function in a script like this:

put field "my input field" into tString
put 28 into tAsciiChar -- (28 is one of the Ascii characters used for
delimiting data)
put NumCharsInString(tAsciiChar,tString) into tCharCount
answer tCharCount


Does that get you started?



More information about the use-livecode mailing list