Mike, Thanks! You got me started with your first reply. I saw that it was grabbing the first characters of the word, even if not what you wanted. For example, if word was timebandit, but you wanted bandit, it selected "timeba". Also, I messed up incrementing my offset, so it only got the first match correctly. Here is my working code for setting the color for any specified search text in a field.
Again, a HUGE thanks for your efforts! Really appreciate it! I'm sooo happy this finally works! 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 put 1 into tFramePos put 0 into tPreviousOffset repeat while tFramePos <> 0 put wordOffset(strSearch,tResults,tPreviousOffset) into tFramePos put word(tFramePos+tPreviousOffset) of tResults into tFullWord put offSet(strSearch,tFullWord) into tCharOffset if tCharOffset >= 0 then select char (tCharOffset) to (tCharoffset+tLength-1) of word (tFramePos+tPreviousOffset) of field "Results" set the textColor of the selection to red end if put tFramePos + tPreviousOffset into tPreviousOffset -- put tFramePos + tPreviousOffset into tPreviousOffset end repeat select empty end mouseUp On Nov 22, 2011, at 12:43 PM, Mike Bonner wrote: > Last time. I swear. Really. Would help if I'd locate all the quirks before > posting, eh? > > The problem with the last code is that if nothing is found it still hilites > from the beginning of the field for the number of chars in the search > string. So to fix that.. _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode