• MacTech Network:
  • Tech Support
  • |
  • MacForge.net
  • |
  • Apple News
  • |
  • Register Domains
  • |
  • SSL Certificates
  • |
  • iPod Deals
  • |
  • Mac Deals
  • |
  • Mac Book Shelf

MAC TECH

  • Home
  • Magazine
    • About MacTech in Print
    • Issue Table of Contents
    • Subscribe
    • Risk Free Sample
    • Back Issues
    • MacTech DVD
  • Archives
    • MacTech Print Archives
    • MacMod
    • MacTutor
    • FrameWorks
    • develop
  • Forums
  • News
    • MacTech News
    • MacTech Blog
    • MacTech Reviews and KoolTools
    • Whitepapers, Screencasts, Videos and Books
    • News Scanner
    • Rumors Scanner
    • Documentation Scanner
    • Submit News or PR
    • MacTech News List
  • Store
  • Apple Expo
    • by Category
    • by Company
    • by Product
  • Job Board
  • Editorial
    • Submit News or PR
    • Writer's Kit
    • Editorial Staff
    • Editorial Calendar
  • Advertising
    • Benefits of MacTech
    • Mechanicals and Submission
    • Dates and Deadlines
    • Submit Apple Expo Entry
  • User
    • Register for Ongoing Raffles
    • Register new user
    • Edit User Settings
    • Logout
  • Contact
    • Customer Service
    • Webmaster Feedback
    • Submit News or PR
    • Suggest an article
  • Connect Tools
    • MacTech Live Podcast
    • RSS Feeds
    • Twitter

Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition

Introduction  |  Table of Contents

Page Prev and Page Next buttons at bottom of the page.

Would you like a hard copy
or PDF of this Guide?

You can get a hard copy sent to you
AND download a PDF now ($19.95)
, or

... just download a PDF ($9.95).

Either way, you get a complimentary
MacTech Magazine Subscription

courtesy of the
Microsoft Mac Business Unit


 

  Magazine Reg. Price:  $50.00 value  
  Guide Reg. Price:  $40.00 value  
  You Save:  over $80.00!  

April, 2007
Page 129



end tell

Note the where its instead of whose in the second line. In this case it is not optional, but mandatory: otherwise you will get an empty list {}. That is because Entourage, rather unfortunately, uses the same keyword 'category' both for this property of contact (and of other objects too) and also for the category class. (Every category you create in the UI or by script is a member of the category class.)

When used in a whose filter, AppleScript gets confused by the namespace conflict between a class and property of the same name, and gives priority to the class over the property. Since there are obviously no contacts which have the category class (they're all of contact class) the result is {} – always empty. But by using an equivalent formulation that includes the magic word its, thus pinpointing contact, not the application, as the container and category as its property, all becomes clear and you get the true result you're looking for. (You need to do the same thing when filtering on every message of some folder where its account is… .)

When the developers came to create the new class project in Entourage 2004, they had learned this lesson, and named the corresponding property of contact, event, etc. project list – so there is no conflict and you can use whose with abandon.

Also note the other pronoun my in the first line of the repeat block. That optimizes iterating through lists – by an enormous degree when the list is large. It can be dozens or hundreds of times faster, so use it. But it only works at the top level of a script, not in a handler unless you declare the list (categoryContacts) as a global variable at the top of the script in which you iterate in a handler. (There is also another method that can be used within handlers, requiring script objects: see the Neuburg book.)

Recipients Group (Make New Group)

Do you ever get email messages that were sent to a large number of recipients – perhaps from someone who sends out a newsletter? You might want to be able to email all the same people, as a group, yourself. Wouldn't it be nice if you could put all the recipients into a group in your Address Book so that you could send messages to the same set of people?

Entourage offers only "Add Sender to Address Book" from a rule or "Add to Address Book" when you click on a single name and address, one at a time – there's nothing for adding multiple recipients anywhere. This script will do it for you. First select the message in question, then run the script:

tell application "Microsoft Entourage"

     display dialog "Enter a name for the group to be made from " & ¬

          "the To recipients of selected messages:" default answer "" with icon 1

     set groupName to text returned of result

     display dialog "Do you want the group set to show " & ¬

          "individual addresses or NOT show addresses in messages " & ¬

          "to the group?" buttons {"Cancel", "Show addresses", ¬

          "Don't show"} default button 3 with icon 1

     if button returned of result = "Don't show" then

          set showOnlyName to true

     else

          set showOnlyName to false

     end if

    

     set theGroup to make new group with properties ¬

          {name:groupName, show only name in messages:showOnlyName}

     set selectedMessages to (current messages)

    

      set entryAddresses to {} -- initialize an empty list

     repeat with i from 1 to (count selectedMessages)

          set theMsg to item i of my selectedMessages

         



< Previous Page Next Page>
 
MacTech Only Search:
Community Search:

 
 
 

 
 
 
 
 
  • SPREAD THE WORD:
  • Slashdot
  • Digg
  • Del.icio.us
  • Reddit
  • Newsvine
  • Generate a short URL for this page:



MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797
MacTech is a registered trademark of Xplain Corporation. Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, Apple Expo, MacTech Central, MacTech Domains, MacNews, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.
All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
 
Nov. 20: Take Control of Syncing Data in Sow Leopard' released
Nov. 19: Cocktail 4.5 (Leopard Edition) released
Nov. 19: macProVideo offers new Cubase tutorials
Nov. 18: S Stardom anounces Safe Capsule, a companion piece for Apple's
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live