• 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: SmartSet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SmartSet


  • Subject: Re: SmartSet
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 18 Dec 2013 23:38:28 +1100

So you need to save the script as a .scptd file in ~/Library/Script Libraries/ or /Library/Script Libraries/. If you're using Script Debugger, use the ASObjC template; if AppleScript Editor, save, click on the Bundle Contents button top-right,  click on the AppleScript/Objective-C Library checkbox, and save again.

The idea is that you create a SmartSet, manipulate it, then return it as a list using asList(). So for example:

use theLib : script "SmartSet lib" -- or whatever you called it

set mySet to theLib's smartSetWith:{4, 6, 1, 2, 3, 7, 1, 4, 3, 3, 7}
set uniqueList to mySet's asList()

This returns the list with duplicates removed. Or:

set mySet to theLib's smartSetWith:{4, 6, 1, 2, 3, 7, 1, 4, 3, 3, 7}
mySet's standardSort()
set sortedList to mySet's asList()

If you run the following and look at the log, you'll probably get more idea:

set mySet to theLib's smartSetWith:{4, 6, 1, 2, 3, 7, 1, 4, 3, 3, 7}
log mySet's asList()
log (mySet's containsObject:8)
log (mySet's containsObject:1)
mySet's standardSort()
log mySet's asList()
mySet's insertObject:"hello" atIndex:2
log mySet's asList()
mySet's swapObjectAtIndex:2 withObjectAtIndex:-2
log mySet's asList()
mySet's replaceObjectAtIndex:-1 withObject:"blah"
log mySet's asList()
log (mySet's objectsFrom:3 toIndex:5)
mySet's removeObjectsFrom:3 toIndex:5
log mySet's asList()
mySet's unionSet:{6, 4, 8, 1, 4}
log mySet's asList()
mySet's minusSet:{6, 4, 9, 11}
log mySet's asList()
log (mySet's isSubsetOf:{6, "blah", 9, 1, 8})
log (mySet's containsObjects:{1, 8})

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >SmartSet (From: Shane Stanley <email@hidden>)

  • Prev by Date: SmartSet
  • Next by Date: Re: SmartSet
  • Previous by thread: SmartSet
  • Next by thread: Re: SmartSet
  • Index(es):
    • Date
    • Thread