• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need a faster Find Duplicates Routine
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need a faster Find Duplicates Routine


  • Subject: Re: Need a faster Find Duplicates Routine
  • From: Paul Skinner <email@hidden>
  • Date: Wed, 28 May 2003 01:07:10 -0400

On Tuesday, May 27, 2003, at 04:27 PM, Paul Skinner wrote:

snip big old ugly wart covered handler that I tested but didn't read through before posting.



On Tuesday, May 27, 2003, at 09:44 PM, Gary Lists wrote:

I read with interest Paul Skinner's handlers posted in reply. That was slow read for me...but the handlers are quite swell. (Thanks, Paul S.)


Gary, it might not have been such a pain to follow if it wasn't so riddled with unused code, cruft and development detrius from long ago.
Warts removed. Same script...


set theIndex to {}
set list1 to {"million", "Karl", "wieners", "buns", "condiments"}
set list2 to words of (read file ((choose file) as text))

repeat with currentSearchTerm in list1
set the end of theIndex to {currentSearchTerm as text, my ItemIndex({searchTerm:currentSearchTerm, inputList:list2})}
end repeat
theIndex
-->{{"million", {160, 214, 245, 296, 361, 492, 684}}, {"Karl", {579, 646, 672, 899}}, {"wieners", {754, 1200, 1279}}, {"buns", {756, 1209}}, {"condiments", {758, 1211}}}

on ItemIndex(parameters)
set rareDelimiter to ASCII character 240
set {prevTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {rareDelimiter & rareDelimiter}}
set indices to {}
set previousItemsIndex to 0
set inputList to ({rareDelimiter} & inputList of parameters & {rareDelimiter}) as text
set AppleScript's text item delimiters to {rareDelimiter & searchTerm of parameters & rareDelimiter}
set inputList to (text items of inputList)
set AppleScript's text item delimiters to {rareDelimiter & rareDelimiter}
repeat with i from 1 to ((length of inputList) - 1)
if item i of inputList is rareDelimiter & rareDelimiter then
set subItems to 1
else
if item i of inputList is "" then
set subItems to 0
else
set subItems to (length of (text items of (text 2 thru -2 of (item i of inputList))))
end if
end if
set thisOccurancesIndex to previousItemsIndex + subItems
set the end of indices to thisOccurancesIndex
set previousItemsIndex to thisOccurancesIndex + 1
end repeat
set AppleScript's text item delimiters to prevTIDs
return indices
end ItemIndex


Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Need a faster Find Duplicates Routine (From: Paul Skinner <email@hidden>)

  • Prev by Date: Re: iTunes 4.0.1 and artwork success
  • Next by Date: Do you get TYPE 2 error while using 'Create New Message'?
  • Previous by thread: Re: Need a faster Find Duplicates Routine
  • Next by thread: Re: Need a faster Find Duplicates Routine
  • Index(es):
    • Date
    • Thread