Colouring words

Peter M. Brigham pmbrig at
Tue Aug 11 19:05:47 CEST 2015

On Aug 10, 2015, at 12:15 PM, Richmond wrote:

> On 10/08/15 19:03, Mike Bonner wrote:
>> oh. Assuming you're on a version of lc that supports truewords
> Mine all seem to support falsewords . . .
> Err, sorry, the mask slipped there a minute :/
> I see that version 7.0.5 supports truewords, and that's good enough for me.
> Thanks for that one.

Here's a quick and dirty command that does what you want. Requires the utility function wordoffsets(), which I posted a few days ago on another thread, also available in the Master Library. Call it by specifying the word, the color, and the field ref:

   colorizeWord "was", "red", the long id of fld "text"

on colorizeWord pWord, pColor, fLongID
   put the text of fLongID into fText
   put wordoffsets(pWord,fText,true) into offList
   lock screen
   -- speeds up the routine considerably, as the screen refresh
   --    only is done once
   repeat for each item i in offList
      set the textColor of word i of fLongID to pColor
   end repeat
end colorizeWord

You could modify this for LC 7+ to use trueword -- expand wordoffsets() to create a new function truewordoffsets(). Yet another example of how the offsets()/wordoffsets()/lineoffsets() functions make life so much easier…. (All these are in the Master Library.)

Richmond: you may want to rename the function to "colourizewords".   :-)

-- Peter

Peter M. Brigham
pmbrig at

More information about the use-livecode mailing list