[futurebasic] Re: [FB] Apple address book

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2006 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Fri, 20 Jan 2006 21:41:25 -0500
Steve wrote:

>that works, with several missing values being returned and
>the -1753 error code at the end with maxrecords set at 100

Steve,

Thanks. I think you will find that you have less than 100 records in 
your AddressBook, and where missing values are reported, they 
actually are missing. AddressBook has a funny default way of entering 
information, When you click on the input box, it is magnified, often 
overlapping it's neighbor. It's easy to enter multiple fields in one 
without realizing it. At any rate, this cleaned up code should work.

Ken


/*

     Retrieve AddressBook Information

     Ken Shmidheiser
     20 January 2006

     Revised

*/

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" + str$(who)
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"