Great Tip from Ken Ray about lineOffset
Alex Tweedly
alex at tweedly.net
Fri Mar 25 05:46:00 EST 2005
Brian Yennie wrote:
> Here's another interesting one to mull over what it does, just for fun:
>
> replace (the lineDelimiter) with (the itemDelimiter) in tList
> put (itemOffset(tItem, tList) div itemsPerLine) into tLineNumber
> if (tLineNumber > 0) then add 1 to tLineNumber
>
> To ponder: why would this be useful for searching data with a fixed
> number of items per line many times?
>
I guess I don't understand the code, or something.
If the item I am searching for is the very first item, then the
itemOffset() returns 1, so the div produces 0 which goes into
tLineNumber. Therefore the if test is false, so I don't add the 1 -
leaving me with a value of 0.
I'd interpret that to mean "item not present", since there isn't a line
number 0.
Am I missing something obvious ?
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.8.1 - Release Date: 23/03/2005
More information about the use-livecode
mailing list