Find

Ken Ray kray at sonsothunder.com
Thu Apr 25 09:37:01 EDT 2002


Jim,

> function getLines tName, tNames
>    repeat with i = 1 to the number of lines in tNames
>      if tName is in line i of tNames then put i & return after results
>    end repeat
>    return results
> end getLines

Just a quick caveat on your script... since you use "is in" you might get a
match on "John" for lines that say "Johnny" or "Johnson". One cool way
around this is to use the wholeMatches property and the lineOffset function:

function getLines tName,tNames
  set the wholeMatches to true
  put 0 into offsetLines
  put "" into returnVal
  repeat
    put lineOffset(tName,tNames,offsetLines) into tLine
    if tLine = 0 then exit repeat
    put (tLine+offsetLines) into line (the number of lines of returnVal)+1
of returnVal
    put (tLine+offsetLines) into offsetLines
  end repeat
  return returnVal
end getLines

Just my $0.02,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/




More information about the use-livecode mailing list