Something like charIndex, but in a variable...

Ben Rubinstein benr_mc at cogapp.com
Fri May 1 06:53:51 EDT 2015


Hi Alex,

Yes that's that approach I was trying to make a relatively general version of 
(see my response 16:50) to handle arbitrarily complex chunk expressions - but 
it would still fail (in fact probably worse?) with chunk 1.  But I think the 
principle is right.

Ben

On 30/04/2015 23:26, Alex Tweedly wrote:
> Not quite so straightforward, but  you can do
>
> function getCharIndexByLineToken pVar, pLine, pToken
>    local temp
>    put the number of chars in line 1 to (pLine-1) of pVar into temp
>    add 1 to temp   -- for the CR between lines 14 and 15 !!
>    add the number of chars in token 1 to (pToken-1) of line 15 of pVar to temp
>    return temp
> end getCharIndexByLineToken
>
> Unfortunately you need different functions for token, word, etc. unless you
> want to make it more complex and (probably) need to use "do" or "value"
>
> Hmmm - and maybe you need to watch that "add 1" in the case of pLine being 1 !!
> or beyond the end ?!?
>
> -- Alex.
>
>
>
>
> On 30/04/2015 09:07, Malte Brill wrote:
>> Hi all,
>>
>> I need to find the start and end character of chuncks in a variable. If we
>> are in a field we can use charIndex for that. However, in a variable I have
>> no good idea on how to do something similar to
>>
>> get charIndex(token 7 of line 15 of field „myField“)
>>
>>
>> Any ideas?
>>
>> All the best,
>>
>> Malte





More information about the use-livecode mailing list