Colouring words

Richmond richmondmathewson at gmail.com
Mon Aug 10 08:57:52 EDT 2015


On 10/08/15 14:45, Mark Schonewille wrote:
> Hi Richmond,
>
> It may not be as easy as you think:
>
> repeat with x = 1 to number of words of line y of fld "What"
>   if word x of line y of fld "What" is "only" then
>     set the textColor of word x of line y of fld "What" to red
>   end if
> end repeat
>
> or
>
> put the htmlText of fld "What" into myText
> replace "only" with "<font color=" & quote & \
>   "red" & quote & ">only</font" in myText
> set the htmlText of fld "What" to myText
>
> Both approaches have advantages and disadvantages.
>
> -- 
> Best regards,
>
> Mark Schonewille
>
>

<snip>

> On 8/10/2015 13:39, Richmond wrote:
>> what is wrong with this:
>>
>> if line 5 of fld "WHAT" contains "only" then
>>           set the textColor of "only" in line 5 of fld "WHAT" to red
>>           end if
>>
>> ???
>>
>> I would like to set certain phrases in a sentence to a different
>> textColor to the other words . . .
>>
>> . . . should be dead easy.
>>
>> Richmond.

Oh, well . . .

I was well aware I could do this:

on mouseUp
    set the textColor of word 3 of line 1 of fld "WHAT" to red
end mouseUp


it just seemed incredibly longwinded to have to write stuff like this:

on mouseUp
    if word 3 of line 1 of fld "WHAT" is "only" then
    set the textColor of word 3 of line 1 of fld "WHAT" to red
    end if
end mouseUp

and then, as you have suggested, write a routine to trawl through all 
the words in a line.

Richmond.




More information about the use-livecode mailing list