Hi Dick Thank you so much for your time in sending me this solution. I’ve already learned a lot and I have yet to actually play with it!
Cheers, Roger > On Mar 14, 2022, at 5:08 PM, Dick Kriesel via use-livecode > <[email protected]> wrote: > > > >> On Mar 13, 2022, at 1:05 PM, J. Landman Gay via use-livecode >> <[email protected]> wrote: >> >> On 3/12/22 8:54 PM, Roger Guay via use-livecode wrote: >>> I have a field with about a thousand lines with many duplicate lines, and I >>> want to delete the duplicates. Seems like this should be simple but I am >>> running around in circles. Can anyone help me with this? >> >> Making the list into an array is the easiest way but as mentioned, it will >> destroy the original order. If the order is important then you can restore >> it with a custom sort function... >> > > > Since order must be maintained, it’s probably faster not to split and sort, > and faster not to scan the list repeatedly using lineOffset or contains. > You could do it like this: > > command removeDuplicates pDelimitedList, pDelimiter > local tArray, tList > set the lineDelimiter to pDelimiter > repeat for each line tLine in pDelimitedList > if not tArray[tLine] then -- i.e., if this line hasn't appeared already, > then ... > put true into tArray[tLine] > put tLine & pDelimiter after tList > end if > end repeat > delete last char of tList > return tList for value > end removeDuplicates > > — Dick > _______________________________________________ > 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
