lineoffset and itemoffset alltogether

Rob Cozens rcozens at
Fri Dec 12 15:08:57 EST 2003

>Is there a function that returns at the same time the lineoffset
>and the itemoffset of a searched string (for instance in the
>form 15,4 for "item 4 of line 15") ?


>I tried to find a workaround. I actually have a variable
>that contains a large number of lines, and each line
>contains the same number of items. I thought I could
>use itemoffset straight (instead of lineoffset) and then
>compute the # of the line with a simple calculation.
>But things aren't so simple... Here's what I mean :
>let's say with have a fld with 2 lines, each line containing
>5 items :
>if you type "select item 5 of line 1 of fld 1" in the msg box,
>"e" will be selected.
>"select item 1 of line 2 of fld 1" will select "f".
>But if you type "select item 5 of fld 1" then "e" and return
>and "f" will be selected.


function lineItemOffset targetText,searchString
   put the number of items of line 1 of searchString into itemsPerLine
   replace return with comma in searchString
   put itemOffset(targetText,searchString) into rawItemNumber
   get rawItemNumber mod itemsPerLine
   if it is 0 then return (rawItemNumber div itemsPerLine)&comma&itemsPerLine
   else return ((rawItemNumber div itemsPerLine)+1)&comma&it
end lineItemOffset


Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)

More information about the Use-livecode mailing list