Ken, I really appreciate this example. It gives me a foundation to build upon. The example doesn't work quite right in that it keeps printing the number 175, but I will figure it out. I really need to learn about Applescript. It appears it can be a very useful tool in FB. Doug On Jan 20, 2006, at 12:21 PM, Ken Shmidheiser wrote: > Doug Stemen asked: > >> Can someone tell me how to access Apple's address book with FB? I >> would like to be able to import names and addresses from it into my >> accounting program. > > Doug, > > You could use the AddressBook framework, but it's a bear, > especially since, as far as I know, the headers have not yet been > translated for FB. > > Another option would be to call a script from Unix to export the > AddressBook contents to a file, and then parse the file contents. > > Another option is this simple AppleScript example I put together > for you. The first function obtains the number of records in your > AddressBook. The second parses out some basic name, address and > phone number information. With that information, it's easy to > iterate through the phone book. > > This may be enough for your purposes. > > Ken > > /* > > Retrieve AddressBook Information > > Ken Shmidheiser > 20 January 2006 > > */ > > include "Subs AppleScript.Incl" > > clear local mode > local fn AddressBookEntries > dim as OSErr err > dim as str255 result > dim as long entries > > route _toApplescript > print "tell application ""Address Book""" > print "set result to the count of people" > print "return result" > print "end tell" > route _toScreen > > err = usr AppleScriptRun( result ) > long if (err == _noErr) > entries = val( result ) > h = Usr AppleScriptGetResult > if h then disposeHandle(h) > xelse > entries = -1 > end if > > end fn = entries > > > clear local mode > local fn GetAddressBookInfo$( who as long ) > dim as OSErr err > dim as str255 result > dim as handle h > > route _toApplescript > print "tell application ""Address Book""" > print "set info to """" > print "set temp to properties of person " + str$(who) > print "set addr to properties of address 1 of person 1" > print "set the phon to the value of phone 1 of person "¬ > + str$(who) > print "set info to name of temp" > print "set info to info & return & street of addr" > print "set info to info & return & city of addr" > print "set info to info & "", "" & state of addr" > print "set info to info & "" "" & zip of addr" > print "set info to info & return & phon" > print "return info" > print "end tell" > route _toScreen > > err = usr AppleScriptRun( result ) > long if (err == _noErr) > h = Usr AppleScriptGetResult > if h then disposeHandle(h) > xelse > result = str$( err ) > end if > > end fn = result > > window 1 > > dim as long i, entries > dim as str255 s > > entries = fn AddressBookEntries > print "You have"; entries; " entries in your AddressBook:" > print > > for i = 1 to entries > s = fn GetAddressBookInfo$(i) > s = mid$( s, 2, s[0] -2 ) > print s; chr$(13) > next i > > include "Subs Quick Event Loop.Incl" > > -- >