Can lineOffSet find last occurance?

Sarah sarahr at genesearch.com.au
Sun Sep 1 20:59:00 CDT 2002


I'm not sure if this is exactly what you want but here is a function I 
wrote to return all the line numbers containing some specific text. You 
could use this and then take the first & last line numbers to limit 
your processing.

function findLines listToSearch, textToFind
   put empty into foundLines
   put 0 into startLine
   repeat
     put lineOffset(textToFind,listToSearch,startLine) into theLine
     if theLine = 0 then
       exit repeat
     else
       put (theLine+startLine) & cr after foundLines
       add theLine to startLine
     end if
   end repeat
   return foundLines
end findLines

Alternatively, how about finding the starting line, then using a repeat 
for each but doing exit repeat if the current line doesn't contain your 
text. The filter command is very fast too. I suggest some timing tests 
to see what is the best option for your data.

Sarah


On Saturday, August 31, 2002, at 04:28  am, Bill Vlahos wrote:

> I need to process a subset of lines in a field which has been sorted. 
> All of the group of lines I want are together because of the sort. 
> What I'm doing now is using a repeat for each line command and 
> checking each line to see if it contains what I'm looking for. This 
> works fine but will eventually slow down with big data sets. I would 
> like to use the repeat for each feature which includes the starting 
> and ending lines.
>
> The lineOffSet command neatly finds the first line of what I want but 
> how can I find the last line? Can lineOffSet be made to start and the 
> end?
>
> I could leave the check for what I want and exit the handler after 
> starting at the offset but it should be faster if I could remove the 
> check. I am confident that the sorting will put what I want together.
>
> Another option would be to put the field into a variable and then 
> filter the variable and do the processing on what remains. I don't 
> know how much of a performance hit the putting and filtering would be. 
> This lineOffSet command seems pretty fast.
>
> Thanks,
> Bill Vlahos
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>





More information about the use-livecode mailing list