"lineAtOffset"?

Kay C Lan lan.kc.macmail at gmail.com
Fri Oct 30 07:51:39 EDT 2015


On Fri, Oct 30, 2015 at 3:33 AM, Richard Gaskin <ambassador at fourthworld.com>
wrote:

>
>   get lineoffset("foo", tText,"","text")
>
> Why wouldn't you make it work similar to matchText(), ie matchText returns
true or false regardless of whether you include a 'foundTextVarsList' but
if your regular expression contains parenthesis and you have a
foundTextVarsList then matchTextI() additionally populates variables for
you.

if matchText(tPhoneNos,"1-800 (.+)",tFreePhone) = true then
  --the result is true then tFreePhone is populated
  --the result is false then tFreePhone is empty

So why not make lineOffSet always return the line number, as it already
does, but include the text of the line if you add an optional parameter
variable to store it in?

get lineOffSet("foo",tText,3) -- returns the line number only


if lineOffSet("foo",tText,3,tTextOfFoundLine) > 55 then
  --the result is > 0, tTextOfFoundLine is populated

  --do something based on lines above 55
else
 --the result is > 0, tTextOfFoundLine is populated

  --do something base on lines 55 or less

end if
  --the result is 0 then tTextOfFoundLine is empty



More information about the use-livecode mailing list