Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 21. Scripting Apple Applications > Scripting Mail - Pg. 635

CHAPTER 21: Scripting Apple Applications 635 The last two lines in the repeat loop are responsible for "removing" the chosen track from the found_tracks list. As you learned in Chapter 10, although AppleScript allows scripts to add items to an existing list, it doesn't provide a way to remove them. The solution is to construct a new list containing all of the previous list's items except for the item we don't want. One option would be to use the remove_item_from_list handler from Chapter 10. However, as we know this list will only ever contain references, a simpler solution is to replace the item we don't want with a non-reference value such as missing value, and then ask the list for all of its reference elements. We then assign this new list to the found_tracks variable, replacing the previous list, and continue looping until we have processed the desired number of tracks. Finally, we send iTunes a play command, passing it a reference to the playlist we want it to play: play my_playlist end tell TIP: If you have previously enabled the system-wide Scripts menu, why not save this script as ~/Library/Scripts/Applications/iTunes/Update My Themed Playlist.scpt (creating any intermediate folders as necessary)? In addition to providing a quick and easy way