Ronald, Peter got in before I did with a great answer: I'll follow it up with mine anyway just for a different perspective. My idea was to separate the search function from the line coloring to speed things up a little. Perhaps by now textColor can apply to variables also. I've fallen behind.
----------------------------- ---- fld "all_fld" ----------------------------- william,a,a,a,a kate,b,b,b,b charles,c,c,c,c harry,d,d,d,d ----------------------------- ---- fld "rural_fld" ----------------------------- queen,a,a,a kate,b,b,b,b charles,c,c,c,c king,d,d,d,d ----------------------------- ---- fld "output_fld" ----------------------------- william,a,a,-,a kate,b,b,rural,b -- RED charles,c,c,rural,c -- RED harry,d,d,-,d --------------------------------------- --- Code -- Watch out for lines wrapping --------------------------------------- on mouseUp set the itemDelimiter to comma -- instead of tab for testing and explanation put fld "all_fld" into list_1247 put fld "rural_fld" into list_436 put cr before list_436 ---------------------------- repeat for each line cur_line in list_1247 ---------------------------------------- put cur_line into new_line put item 1 of cur_line into cur_item put cr & cur_item & comma into find_this -------------------------------------- put "-" into item 4 of new_line if find_this is in list_436 then put "rural" into item 4 of new_line end if put new_line & cr after new_list end repeat ---------------------------------------- put new_list into fld "output_fld" put zero into k_count repeat for each line k in new_list add 1 to k_count if "rural" is in item 4 of k then set the textColor of line k_count of fld "output_fld" to "red" end if end repeat end mouseUp --- On Thu, 4/28/11, Peter Brigham MD <[email protected]> wrote: From: Peter Brigham MD <[email protected]> Subject: Re: comparing content of two fields To: "How to use LiveCode" <[email protected]> Date: Thursday, April 28, 2011, 7:41 AM On Apr 27, 2011, at 11:55 PM, Ronald Zellner wrote: > I have two data fields that have multiple tabbed columns, > I want to determine which items in the main field (1247 lines) also appear > in the second field (436 lines). > > Using this code to compare line by line: > > on mouseUp > > set the itemDelimiter to tab > repeat with x = 1 to the number of lines in field "All" -- there are 1247 >lines > > repeat with y = 1 to the number of lines in field "Rural" --there are >436 lines > if item 1 of line x of field "All" = item 1 of line y of field >"Rural" then > put "Rural" into item 4 of line x of field "All" > set the textColor of line x of field "All" to "red" > exit repeat > else > put "-" into item 4 of line x of field "All" > end if > > end repeat > end repeat > end mouseUp Try this: on mouseUp put fld "All" into allEntries put fld "Rural" into ruralEntries set the itemDelimiter to tab repeat with x = 1 to the number of lines in allEntries -- there are 1247 lines if cr & (item 1 of line x of allEntries) & tab is in cr & ruralEntries then put "Rural" into item 4 of line x of field "All" set the textColor of line x of field "All" to "red" exit repeat else put "-" into item 4 of line x of field "All" end if end repeat end mouseUp -- Peter Peter M. Brigham [email protected] http://home.comcast.net/~pmbrig _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
