Line offset of an item (and other similar functions).
Sarah Reichelt
sarahr at genesearch.com.au
Mon Jan 24 22:02:16 EST 2005
> I do want to match only whole items, so as to avoid false positives
> (i.e. item "alex1" should not match "alex123")
>
> lineOffset will give me the line number - but there's no way to say
> "match whole items only"
> itemOffset will find the right instance (given wholeMatches set to
> true), but it gives me item number, not line number
> matchChunk will find it for me - but gives character positions, not
> line number
>
> I'm hoping there's some way to inveigle one of the 'offset' functions
> to do this.
The docs say wholeMatches works with lineOffset, so if it doesn't, you
should bugzilla that as either a bug or a docs error.
>
> Alternatively is there some way to convert chunk expressions between
> types, e.g.
> given myVar containing
>
>> abc,def,ghi
>> 12, 34, 56
>> a1,b2,c3,d4
>
> convert an expression such as item 3 to 5 of myVar to the
> corresponding char/word/line expression (i.e. char 9 to 17 or word 1
> to 3 or line 1 to 2).
> Any suggestions on how to do it ?
>
If you get a result that specifies say "item 3 of line 5 of myVar", you
can then say:
put the number of chars in item 1 to 2 of line 5 of myVar into tStart
put the number of chars in item 3 of line 5 of myVar into tLen
Then you can construct your chunk expression:
char tStart to tStart+tLen of line 5 of myVar
This is untested and you may need to add or subtract 1 from these
variables, but this should give you the idea.
Cheers,
Sarah
More information about the use-livecode
mailing list