text color
Mike Bonner
bonnmike at gmail.com
Tue Nov 22 12:24:56 EST 2011
Oh, my last response was in your second set of code that you was causing a
syntax error. The complete code is as follows.
on mouseUp
set the traversalOn of field "Results" to true
put the text of field Results into tResults
put the text of field "SearchField" into strSearch
put the length of strSearch into tLength -- yep, like this.
put 1 into tFramePos
put 0 into tPreviousOffset
repeat while tFramePos <> 0
-- noticed in your posted code that you used itemoffset instead of
wordoffset. I assume this was a typo.
put wordOffset(strSearch,tResults,tPreviousOffset) into tFramePos --
locat the beginning of the word
-- since its word offset rather than straight offset, define the chunk
explicitly.
-- char 1 to the length of the string, of the word that was found, of the
field it was found in.
select char 1 to tLength of word (tFramePos+tPreviousOffset) of field
"Results"
set the textColor of the selection to red
put tFramePos + tPreviousOffset into tPreviousOffset
end repeat
select empty
end mouseUp
You could just use offset rather than wordoffset since you aren't looking
for whole word matches. Wouldn't be too difficult to rewrite it that way.
Either will work dandy.
More information about the use-livecode
mailing list