Can lineOffSet find last occurance?

Sarah sarahr at
Sun Sep 1 20:59:00 EDT 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
     put lineOffset(textToFind,listToSearch,startLine) into theLine
     if theLine = 0 then
       exit repeat
       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.


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

More information about the Use-livecode mailing list