Highlight instances of found text

Sivakatirswami katir at hindu.org
Sun Jul 5 00:39:45 EDT 2009


Mark Swindell wrote:
> Something like this ought to work:
>
> ON mouseUp
>     REPEAT WITH x = 1 to the number of words in field 1
>         IF word x of field 1 is theFoundWord THEN
>             set the backgroundcolor of  word x of field 1 to yellow
>         END IF
>     END repeat
> END mouseUp
>
> hth,
> Mark

Thanks Mark... this almost works

1) only works for single words

2) and one must use "contains" if you want to pick up everything bounded 
by punctuation
and part of hyphenated words.

ON mouseUp
    REPEAT WITH x = 1 to the number of words in field 1
        IF word x of field 1 contains theFoundWord THEN
            set the backgroundcolor of  word x of field 1 to yellow
        END IF
    END repeat
END mouseUp

3) But fails for any strings with spaces in it.  I'm cogitating how to 
do just as efficient a loop to target matching string chunks, but will 
probably need to sleep on it first (smile)... I think I have an looping 
off set function somewhere that should work...

I need to get more organized with my library of already build tools!








>
>
> On Jul 4, 2009, at 4:41 AM, Sivakatirswami wrote:
>
>> Does anyone have a function that will highlight/colorize instances of 
>> found text in a field?
>>
>> e.g. say we have a search function, user types "chapati"
>>
>> In the particular ebook I have, all instances (lines or paragraphs 
>> containing) of "chapati" are "gathered" and then posted to a field 
>> for review... I would like to have all instance of "chapati" in that 
>> field be highlighted or colorized.
>>
>> I'm sure I can figure it out but someone I'm sure has already cooked 
>> this dosai before and I'm a fan of using recipes.
>>
>> Thanks
>> Sivakatirswami
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list