Counting Chars By ASCII Part 2

Mark Smith mark at maseurope.net
Wed Mar 1 11:17:25 EST 2006


I've come up with this:


on anotherOne
   put fld 1 into tString
   repeat with n = 1 to 30
     if (n >= 10 AND n <=12) OR n = 29  then next repeat
     put n & tab & charCount(n,tString) & cr after tList
   end repeat

   put tList into fld "chars"
end anotherOne

function charCount n,tString
   put length(tString) into oLen
   replace numToChar(n) with empty in tString
   return oLen - length(tString)
end charCount

Of course this won't find chars > 255, but then I have a question -

if you insert "set the useUnicode to true" at the beginning of it, it  
still works, however if you do the same with your handler, on my  
system, it takes four time longer, and produces no result. Without  
the useUnicode setting, surely we're only able to count chars with an  
ascii value <= 255...or have I misunderstood this ascii 1-byte, 2- 
byte stuff?

Mark

On 1 Mar 2006, at 15:41, Jonathan Lynch wrote:

> How is the speed on the script you are using?
>
> Like, if you use this script on a string of several megabytes, how  
> long does
> it take to get a result?
>
>
> Since you are testing for a number of possible different  
> characters, you are
> going to have to use a repeat for each char loop - I think.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list