Hi Ken,

> This one is slightly faster, but is less lines:
> 
> function delimCount tStr,tDel
>   replace tDel with CR in tStr
>   return the number of lines of (tStr & null)
> end delimCount

But it will not give the desired results if there are line breaks to begin 
with, you need the line
> if tChar <> CR then replace CR with "" in tStr
here as well.

As Jim pointed out, I don't need to bother with saving the itemDelimiter (old 
HyperCard habit),
and using your hint, it can be boiled down to

function delimCount strr, del
        set the itemDelimiter to del
        return the number of items in (strr & null)
end delimCount

> Also note that a modified form of this can be used to count any number of
> characters in a string:
> 
> function charCount tStr,tChar
>   if tChar <> CR then replace CR with "" in tStr
>   replace tChar with CR in tStr
>   return the number of lines of (tStr & null)
> end charCount

I tried the different options with the Change_Log_2.6.1.txt file, and there the 
double replacement is slower by a factor of 10.

All the best
Thomas


--
Thomas Fischer
Salzburg 

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to