"lineAtOffset"?

Mark Waddingham mark at livecode.com
Thu Oct 29 16:25:45 EDT 2015


On 2015-10-29 19:47, Geoff Canyon wrote:
> How about:
> 
> line 1 containing x in y
> word 47 containing x in y
> item -3 containing x in y

I must confess I'm not 100% sure of what these mean - I see two 
possibilities:

1) item Z containing x in y - is the first item after item Z which 
contains x where y is the string to search

2) item Z containing x in y - the Z'th item containing x where y is the 
string to search

Interpretation (1) is equivalent to the originally proposed 
'itemAtOffset'. (Okay so it was lineAtOffset, but mutatis mutandis).

Interpretation (2) is something slightly different to what we have now 
and perhaps wouldn't easily fit (obviously) into a functional form.

> Adding an index allows for a natural english syntax, a clear result,
> maximum flexibility, and pathological extension, i.e.:
> 
> word -2 containing "i" in item 14 containing "test" in line 23 
> containing
> "index"

Any non-function like syntax would allow stacking naturally as the 
result of the expression after the 'in' would be evaluated first, so 
actions further to left would evaluate on the substrings produced by 
those to the right (of the 'in').

(Obviously function versions would stack to, but be nested rather than 
left to right).

> This syntax would make it easy to do a more detailed match:
> 
> line 4 matching "a*b" in y

I've always quite liked the idea of:

    item 4 of y where it matches "a*b"

Indeed, that makes me think that you are thinking interpretation (2) 
above (please do correct me if I'm wrong).

Actually, with a 'where' clause, Richard's itemAtOffset function would 
become:

    the first item of y where it contains "a"

In either case (where or containing) I'd be concerned that there is a 
lack of clarity of what 'item N ...' means.

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list