Counting Chars by ASCI Values

Phil Davis davis.phil at comcast.net
Tue Feb 28 15:56:05 CST 2006


Hi Todd,

By high & low ASCII you mean where numeric values can be 0 to 255, 
right?  This will work *IF* the 'caseSensitive' property makes A<>a:

set the caseSensitive to true
repeat for each char tChar in tDataContainer
   -- tally the occurrances of each char in an array
   add 1 to tCounts[tChar] -- no need to convert the char to a num
end repeat

After this finishes, 'the keys of tCounts' will be a list of all chars 
encountered in the data, and tCounts[<anyChar>] will give you the number 
of times that character occurred.

Otherwise you can work strictly with the ASCII values:

repeat for each char tChar in tDataContainer
   add 1 to tCounts[charToNum(tChar)]
end repeat


HTH -
Phil Davis



Todd Geist wrote:
> Hello
> 
> I need to count the number of times a Character occurs in text  string. 
> The character will be high or Low ASCII.  SO I need to input  the value 
> as an ASCII value.
> 
> Anybody have any scripts that can get me started?
> 
> 
> Thanks
> 
> Todd
> 
> 




More information about the use-livecode mailing list