• 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: Trimming down a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trimming down a list


  • Subject: Re: Trimming down a list
  • From: Steve Thompson <email@hidden>
  • Date: Thu, 11 Apr 2002 10:53:37 +0100

The RemovDuplicates Routine (posted at the end of this message) now works
but I still think it's a bug. Or a misunderstanding on my part...

From the sub below:

set thisItem to item i of RemoveDups's listRef

...returns thisItem as {"an item"} but :

set thisItem to item i of RemoveDups's listRef as text

...return thisItem as "an item".


From the first version, adding thisItem to k produces {{"An Item"}} and will
then fail on the next loop as AppleScript doesn't see {"An Item"} in {{An
Item"}}

The lines
{"An Item"} is in {{"An Item"},{"Another Item"}}

And

"An Item" is in {{"An Item"},{"Another Item"}}

... Both return false which confirms this which is the bit that I think is a
bug. A number of people including myself thought it would work so...

Anyway, adding "as text" fixes the problem:

set thisItem to item i of RemoveDups's listRef as text

As this turns {"An Item"} into "An Item" which AppleScript has no trouble
seeing in {"An Item","Another Item"} and it produces the correct result. It
also means that when "Third Item" isn't in the list so

Set end of k to thisItem

...sets k to: {"An Item","Another Item","Third Item"} which is the desired
result.

Just for the record, if anyone ever comes across this kind of problem again
- I receive a file of around 10,000 records each day on which I have to do a
number of data extractions before the relatively simple job of flowing it
all in to a Quark Document to make a report. After a number of posts to this
board and a bit of experimenting, I have discovered that the best tool for
splitting up the data is a piece of software called Valentina and then
extracting the unique items is done using the script which I've added below
(99% of which was written by Paul Berkowitz!). These two things have reduced
a script that took over 2 minutes for 10,000 records using FileMaker and no
references to a script that takes 8 seconds for the same file.

Thanks to everyone who helped - I hope this information helps someone else.


on RemoveDuplicates(longList)

script RemoveDups
property listRef : longList
end script

set k to {}
repeat with i from 1 to (count longList)
set thisItem to item i of RemoveDups's listRef as text
if thisItem is not in k then set end of k to thisItem
display dialog k
end repeat

return k

end RemoveDuplicates
_______________________________________________
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.

  • Follow-Ups:
    • Re: Trimming down a list
      • From: Andy Wylie <email@hidden>
  • Prev by Date: Re: Anyone using Valentina on Mac OS X
  • Next by Date: Obtaining the name of a "dropped" folder
  • Previous by thread: Re: Trimming down a list
  • Next by thread: Re: Trimming down a list
  • Index(es):
    • Date
    • Thread