"lineAtOffset"?
dunbarx at aol.com
dunbarx at aol.com
Thu Oct 29 13:24:08 EDT 2015
Richard.
Ben makes a point. Several, in fact.
FWIW, I have always just:
get line lineOffset(someText,myField) of myField
I bet you have too. So I never found this too onerous. There are a bunch of these little combo-kluges...
Craig
-----Original Message-----
From: Richard Gaskin <ambassador at fourthworld.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Thu, Oct 29, 2015 11:48 am
Subject: "lineAtOffset"?
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
_______________________________________________
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