lineoffset question
Alex Tweedly
alex at tweedly.net
Fri Oct 9 10:32:26 EDT 2026
Hi,
I guess the first question is
do you want the line number as well as the content of the line ?
Mike suggested using regex - which is probably fast - but I'm not sure
how (if?) it could give you the line number.
If you don't need the line number then regex is probably the way to go.
If you do, then it may come down to whether
> put line it of mylist into tLine
>
is faster than the regex.
I'm afraid I don't like your suggestion of
> And if the string to search has been found, the returned
> value could be as follows :
> line 1 -> the line number
> line 2 -> the content of the found line
That would be not backward compatible, so it would break probably 99% of
existing uses :-), it would have to be a new function.
Alex.
On 09/10/2026 08:40, jbv via use-livecode wrote:
> Hi list,
>
> When lineoffset returns a value greater than 0, that
> means the string to search has been found.
> But is there a way to get the content of the found line ?
>
> Of course, I can use :
> get lineoffset(myVar,myList)
> if it > 0 then
> put line it of myList into tline
> end if
>
> But when myList is very long, and when many lines are
> successively found, the script has to count the lines
> each time and it becomes very slow.
>
> There is also the option to split the lines of myList
> into an array :
> put myList into Tlist using return
> get lineoffset(myVar,myList)
> if it > 0 then
> put Tlist[it] into tline
> end if
>
> But then again, splitting the list can be slow if it's
> very long.
>
> IMHO it would be a great improvement to get the content
> of the line in which the string to search has been found.
> For instance, if nothing has been found, the returned value
> would still be zero.
> And if the string to search has been found, the returned
> value could be as follows :
> line 1 -> the line number
> line 2 -> the content of the found line
>
> Best,
> jbv
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list