Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Create a classification feature in Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Create a classification feature in Address Book
Authored by: fitzgunnar on Jan 04, '06 04:19:08AM

Since other people actually seem interested in this feature, I must take the chance to ask if anybody has (or can) come up with a way to restrict the values for the categorisation to a specified set of labels. Some way to prevent that the user accidentally misspell the label 'private' as 'privat', for example.

Any idea?

/MagnusG!



[ Reply to This | # ]
10.4: Create a classification feature in Address Book
Authored by: Lutin on Jan 04, '06 08:01:38AM
I wanted, as suggested, restrict the values for the categorisation to a specified set of labels (and don't have to type / paste-and-copy them each time).

Here we go!

To extend the dialog capabilty of Applescript, this script uses 24U Appearance OSAX from http://www.24uSoftware.com/ It must be installed before use.

Select one or more cards in AddressBook and run the script.



-- Script by Lutin
-- Sat Dec 17 2005

-- To extend the dialog capabilty of Applescript
-- this script uses 24U Appearance OSAX from http://www.24uSoftware.com/
-- Must be installed before use

-- Define the categories used to sort the contacts
-- Second field determines if the checkbox is already checked when asked
set myFirst to {"xFamily", true}
set mySecond to {"xFriend", true}
set myThird to {"xSchool", true}
set myFourth to {"xWork", false}
set myFifth to {"xInactive", false}

try
	-- Set up the dialog box with 24U Appearance
	set myResult to display better dialog ¬
		"And, of course, also checkboxes:" fields {¬
		{kind:check box, name:(first item of myFirst), selected:(second item of myFirst)}, ¬
		{kind:check box, name:(first item of mySecond), selected:(second item of mySecond)}, ¬
		{kind:check box, name:(first item of myThird), selected:(second item of myThird)}, ¬
		{kind:check box, name:(first item of myFourth), selected:(second item of myFourth)}, ¬
		{kind:check box, name:(first item of myFifth), selected:(second item of myFifth)}} ¬
		buttons {"OK", "Cancel"}
	
	-- Get in a list all checked checkboxes
	set myChoices to choices returned of myResult
	
	tell application "Address Book"
		-- Get all the cards selected in Address Book
		set thePeople to selection
		
		repeat with aPerson in thePeople
			set aNote to the note of aPerson
			if aNote is missing value then set aNote to ""
			
			-- For each category selected add it to the field note
			repeat with aChoice in myChoices
				if (aNote does not contain aChoice) then
					set note of aPerson to aChoice & "
" & aNote
					set aNote to aChoice & "
" & aNote
				end if
			end repeat
		end repeat
	end tell
	
on error myErr number myErrNum
	if myErrNum = -1708 then
		display dialog "Sorry, an error has occured, probably because " & ¬
			" 24U Appearance OSAX was not installed properly. See http://www.24uSoftware.com/" buttons {"Quit"} default button 1
	else
		error myErr number myErrNum
	end if
end try
It sure has many ways of improvement. Please share your modifications.

[ Reply to This | # ]