Hi,
I am new to this and would really appreciate a experienced eye to help solve a problem with a address book rollover.
Here is what I have…
Mac OS 10.5, using mac Address Book and Script Editor 2.2.1
I have a script which automatically copies all Smart Group and makes new standard groups of the same name other than a _ before the name. I.E. Smart Group name is FRIENDS and the script will automatically create a new group called _FRIENDS and copy all contacts from the smart group to the new _group.
The script works perfectly on its own. I have even made a Folder Action script and enabled it to the meta data folder for address book in the user directory and it works fine whenever I add a new contact.
Now I am trying to make a roll over item that I can run the script from and for now simply using the address field and I cannot get it to run the script. It shows as a rollover, and I can select it, but it does not run it!
Here is the script with the rollover added, any help would be welcome!
(I left the ON in there because that is the script that runs fine on its own. I realize there is a compiling error with the ON command there and have tried many variation to avoid the error)
using terms from application “Address Book”
on action property
return “address”
end action property
on action title
return "Group Sort"
end action title
on should enable action
return true
end should enable action
on perform action
ON replaceString(theText, oldString, newString)
set AppleScript's text item delimiters to oldString
set tempList to every text item of theText
set AppleScript's text item delimiters to newString
set theText to the tempList as string
set AppleScript's text item delimiters to ""
return theText
end perform action
tell application "Address Book"
set theGroups to every group
end tell
repeat with aGroup in theGroups
if id of aGroup contains "ABSmartGroup" then
set theName to "_" & replaceString((name of aGroup), "SM_", "")
tell application "Address Book"
if group theName exists then
remove every person from group theName
else
make new group with properties {name:theName}
end if
add (every person in aGroup) to group theName
end tell
end if
end repeat
tell application "Address Book" to save addressbook
Here is the script that works fine on it’s own. I am trying to have it run as a rollover item in Address Book.
Thanks for your reply.
on replaceString(theText, oldString, newString)
set AppleScript’s text item delimiters to oldString
set tempList to every text item of theText
set AppleScript’s text item delimiters to newString
set theText to the tempList as string
set AppleScript’s text item delimiters to “”
return theText
end replaceString
tell application “Address Book”
set theGroups to every group
end tell
repeat with aGroup in theGroups
if id of aGroup contains “ABSmartGroup” then
set theName to “" & replaceString((name of aGroup), "SM”, “”)
tell application "Address Book"
if group theName exists then
remove every person from group theName
else
make new group with properties {name:theName}
end if
add (every person in aGroup) to group theName
end tell
end if
end repeat
tell application “Address Book” to save addressbook
the action cannot work because it contains only a handler (a subroutine).
The purpose to use these Address Book event handlers is to do an action depending on a specified parameter of a contact.
Your script affects always all contacts, so it might be easier to run it from the script menu
I do have it available on the scripts menu bar, and I also have found 2 ways to have it run automatically.
One is simply by having iCal run the script on a scheduled repeat basis. The 2nd way it by making a folder Action and it runs whenever a new contact is added. I was just trying to further my experience to work with rollovers and could not figure out why it would not run. You have answered that for me and I appreciate it!
Jacques, Your right, it works like a champ!
Next I am going to see if I can modify it to delete ant of the created standard _group if the original Smart Group is deleted.
The purpose of this is due to the fact that the iPhone will not sync Smart Groups !
Thanks again, any pointer on deleting standard group that bear the name _xxxx would be appreciated.