AW: AW: AW: Lines, items, repeat loops, > not always what you think

Jim Ault JimAultWins at yahoo.com
Thu Oct 20 19:11:46 EDT 2005


Hi, Thomas,
Looks like we can boil it down to either

repeat with x = 1 to the number of items in (strr & null)
--or
repeat with x = 1 to the number of lines in (fld listOfMovieTitles & null)

and no function call necessary plus no change in the native data.
The sort will work since the empty will slide as though it exists, even if
it is at the end of the list and a resort moves it to the top.

I am adding (   & null) to my repeats from now on.
This has been a great thread for me and an excellent solution.
Thank you for digging into it like you did, Thomas.

Jim Ault
Las Vegas



On 10/20/05 3:51 PM, "Thomas Fischer" <fischer at mail.sub.uni-goettingen.de>
wrote:

> 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
> 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