Finding list items within a table field

Keith Clarke keith.clarke at clarkeandclarke.co.uk
Sun Jul 14 11:00:24 EDT 2013


Hi folks,
I've posted this question to Stack Overflow - http://stackoverflow.com/questions/17639968/livecode-find-list-items-within-a-table-field - but it seems very quiet over there on LiveCode matters, so apologies for t the cross-posting.

I'm trying to use LiveCode to clean up some contact data. I have two lists:
	SourceList: a list of tab-delimited contact records in a LiveCode table field;
	FlagList: a list of strings, such as 'test' that I want to check for within the SourceList.
Ideally, I want to highlight 'hits' in both the FlagList rows and the matching characters in the items in the rows of the SourceList, but I'm struggling with errors on my first pass. 

On loading the SourceList from file, I'm trying to set the colour of any FlagList field rows that are found in the SourceList.

Here's the script on the 'Load SourceList' button...

on mouseUp
   answer file "Select text file to Clean" with type "txt"
   if it <> "" then
      put empty into field "SourceList"
      put it into field "SourceFile"
      put it into theFilePath
      put URL ("file:" & theFilePath) into field "SourceList"
      
  repeat for each line f in field "FlagList"

     repeat for each line l in field "SourceList"

        repeat for each item i in l
            if i contains f then set the foregroundColor of f to "red"
        end repeat

     end repeat

  end repeat
      
   else     
      --no file was selected, or cancel was pressed
      beep
      end if
end mouseUp

I think I'm making a basic error, so grateful for any guidance. 
Best, 
Keith..


More information about the use-livecode mailing list