Feedback: comparing content of two fields

J. Landman Gay jacque at hyperactivesw.com
Fri Apr 29 03:45:41 EDT 2011


On 4/28/11 10:04 PM, Ronald Zellner wrote:

> Had to remove the color change as you can't set that attribute- as Michael predicted.

Actually you can. Another thing that slows down a script is using a 
counter variable in a repeat loop. Sometimes you have to, but if 
possible use the "repeat for each" structure, which is much faster.

I didn't actually test this so you may need to adjust it, but this 
handler only hits the field to twice and avoids a counter. Using 
htmlText allows you to color the lines without accessing the field 
repeatedly. It should be fast enough that you don't need to have any 
visual progress indicators; using "repeat for each" can typically 
process thousands of lines in a few milliseconds.

on mouseUp
    put fld "All" into allEntries
    put fld "Rural" into ruralEntries
    set the itemDelimiter to tab
    repeat for each line tLine in allEntries
       put tLine into tCurLine
       if cr & (item 1 of tCurLine) & tab is in cr & ruralEntries then
          put "Rural" into item 4 of tCurLine
          put "<p><font color=#FF0000>" &  tCurLine & "</font></p>" 
after tNewList
       else
          put "-" into item 4 of tCurLine
          put "<p>" & tCurLine & "</p>" after tNewList
       end if
    end repeat
    set the htmlText of fld "All" to tNewList
end mouseUp
-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list