find
Sarah
sarahr at genesearch.com.au
Tue Apr 23 01:18:01 EDT 2002
You need to use the optional third parameter for lineOffset which tells
it how many lines to skip before it starts looking. The trick is to
remember that the line number it returns is the line number starting
after the skipped lines, so you need to add the two together to get the
actual line number.
Here is the function I use. The mouseUp script that calls it assumes
your list is in field 1.
on mouseUp
put findLines(field 1, "John") into lineList
answer lineList
end mouseUp
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
Cheers,
Sarah
On Tuesday, April 23, 2002, at 04:02 pm, yves COPPE wrote:
> Hi,
>
> I'd like a script which search for all occurences of a word in a list
> and returns the number of all lines.
>
>
> an example :
>
> a list with :
>
> Peter
> John
> Richard
> John
> George
> John
> Philip
> Tom
>
> So if i call the code for "John", the result should be :
>
> 2
> 4
> 6
>
>
> I've tried with lineoffset but it gives only the first occurence.
>
> thanks.
> -- Greetings.
>
> Yves COPPE
>
> Email : yvescoppe at skynet.be
> _______________________________________________
> 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