• 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
Setting parameters in Address Book
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting parameters in Address Book


  • Subject: Setting parameters in Address Book
  • From: "Robert R. Horning" <email@hidden>
  • Date: Mon, 11 Feb 2008 21:35:19 -0700

Hi Chris,

Yes, I want to pull the property names out of a list. The idea is to dump contact data from a database, making sure that the field names that are dumped are the same as property and element names in Address Book. But the Applescript should be smart enough to decide at run time what those names are, since there will be multiple dumps having different field names. I don't have a compiler for C of any flavor, and have only heard of Ruby and Python. If someone is patient enough to lead me by the hand, I'm certainly willing to learn.

I'm using Excel as an intermediary between the db, which is in MS Access on Windows XP under Parallels, and the Address Book. Data retrieval from Excel works well, thanks to help from people like you. Now I need to get it into the Address Book. Btw, there are hundreds of records in both the db and the Address Book. And I intend to update multiple users' Address Books each night. So this is not something one would want to do manually.

Thanks, Bob.

On Feb 11, 2008, at 6:34 PM, Christopher Nebel wrote:


On Feb 11, 2008, at 4:45 PM, Robert R. Horning wrote:


This last suggestion, and some similar ones in this thread, work just fine. Thanks!!! Now what I need is to store property and element names (not values) in variables, then use the contents of the variables when setting or retrieving property and element values. Thus:

set HerTitle to "Queen"
set MyProperty to "title"
tell application "Address Book"
	set foo to person id michellesid
	tell foo
		set its MyProperty to HerTitle
	end tell
end tell

Setting 'title' to HerTitle works.
Attempting to substitute MyProperty for 'title' doesn't.


That's harder, depending on exactly what you've got in mind. If you know ahead of time the property you want, you can get a reference to it:


	set HerTitle to "Queen"
	tell application "Address Book"
		set MyProperty to a reference to title of person id michellesid
		set contents of MyProperty to HerTitle
	end tell

The trick is that that third line sets MyProperty to not the value of the title property, but a specifier for the title property itself. You can then pass that around, and set (or get) the value by referring to its "contents".

Now, if what you wanted was to pull the property name out of some text somewhere, then you'll need some fairly nasty workarounds for AppleScript. Languages with better introspection abilities such as Ruby or Python don't have as much trouble. I could tell you how to do it in Objective-C in Leopard; I'd have to look up answers for Ruby or Python. I'm sure has could tell you immediately.


--Chris Nebel AppleScript Engineering



_______________________________________________ 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
  • Follow-Ups:
    • Re: Setting parameters in Address Book
      • From: has <email@hidden>
  • Prev by Date: Delete Bug or Feature?
  • Next by Date: Unble to run Script based application
  • Previous by thread: Re: Delete Bug or Feature?
  • Next by thread: Re: Setting parameters in Address Book
  • Index(es):
    • Date
    • Thread