"lineAtOffset"?

Richard Gaskin ambassador at fourthworld.com
Thu Oct 29 11:47:18 EDT 2015


Currently we have the lineOffset function, a very handy way to know the 
number of a line that matches whatever we're searching for in a block of 
return-delimited text.

However, like most chunk expressions it's able to do what it does by 
evaluating every character in the chunk, both looking for the matching 
string and counting CRs as it goes.

Many times when we're using lineOffset it's because what we're after 
isnt the line number but the text of that line.  And getting that 
requires another traversal of the entire chunk to "get line <lineNumber> 
of <chunk>".

Given how handy chunk expressions are in LiveCode, I'm wondering if it 
might be even handier to see the introduction of a new function, 
something that could perhaps be called "lineAtOffset".

Like "lineOffset", "lineAtOffset" would take the same arguments and 
operate similarly, but rather than returning the number of the matching 
line it would return the text of that line.

Questions for you folks:

1. Is this as useful as I think it might be?

2. Is there a better name for the function?

3. Would consistency with wordOffset, trueWordOffiset, and itemOffset 
bog this down to the point where we'd either have to face an 
inconsistent world in which only lineAtOffset is supported or wait much 
longer for a more complete implementation that would also do the others 
(itemAtOffset, etc).  Personally, I'd be fine if this were limited to 
lines since the other chunk types aren't usually long enough in my own 
work to have much impact on performance having to make two calls.  But 
as I've noted before, sometimes I'm too easily satisfied and others may 
have more demanding requirements.

3. Is this worth submitting to the request queue?

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list