Add phone to Address Book person

so far i’v got this : selecting records from FrontBase & adding data to Address Book, except from the phone field / e-mail field
must be something with “at the end of phones” or something like that
always get different errors from applescript compile
don’t understand the :“” syntax in the properties either

tell application “FBScriptAgent”
make new connection at the end of connections
tell last connection
connect hostname “localhost” databaseName “MyDB” username “_system”
set myRows to executeFetchAndCancel numberOfRows 50 sql “select cfirst_name,clast_name,cphone,ccompany from tpersons”
repeat with myrow in myRows
set cfirst_name to item 1 of myrow
set clast_name to item 2 of myrow
set cphone to item 3 of myrow
set ccompany to item 4 of myrow
tell application “Address Book”
– new person
set thisperson to make new person
set myproperties to {first name:“”, last name:“”, organization:“”}
set first name of myproperties to cfirst_name
set last name of myproperties to clast_name
set organization of myproperties to ccompany
set properties of thisperson to myproperties
– new phone
– set thisphone to make new phone at end of phones of thisperson
– set properties of thisphone to {“work”, cphone}
– either
–set thisphone to add phone to end of phones of thisperson
–set myproperties to {label:“”, value:“”}
–set label of myproperties to “work”
–set value of myproperties to cphone
–set properties of thisphone to myproperties
– add to group
add thisperson to group “Imported Addresses”
save addressbook
end tell
end repeat
disconnect
end tell
end tell

there must be something i’m missing, i’m not really familiar with interpreting the dictionnary of Address Book

anyone ?

Model: PowerBook G4
Browser: Safari 312.3
Operating System: Mac OS X (10.3.9)

I too “Love AppleScripting” .

But after looking at your valiant attempt it seems to me that it would be just a lot easier to open your address book and “edit” the person you want by adding a phone.

:smiley:

Hi,

Try something like this:

set the_list to {“work”, “111-222-3333”}
set {the_label, the_value} to the_list
tell application “Address Book”
activate
set p to make new phone at end of phones of first person ¬
with properties {label:the_label, value:the_value}
save addressbook
end tell

gl,

finally got it to work,
several several syntaxes were most of the time correct

but just discovered the reason for this internal script error
as all fields come from a database (frontbase database in this case)
some fields had a value of “missing value”
it took me some time to translate them to an empty string
as missing value is not the same as “missing value”
but now i can import both work phone, work email, work address (including, zip, country name)
after testing for the missing value

Tnx to all who made a contribution or at least the brain hire on sunday

Next thing will be to either insert or update an existing card,
even be it for the sports

Geert