Trying to use Allen Watson's EntourageX-script - help needed!!

Sorry for the stupid question, but it´s very urgent that I’m able to run the script.
I’m trying to use Allen Watson’s script “Categorize Duplicate Contacts” for Entourage X. The following is the part I really need:


	tell application "Microsoft Entourage"
		set full_names to {display name of every contact, ID of every contact}
		-- Recompose the lists to produce {{name,id},{name,id},...}
		say "Continuing to process"
		set full_names to my recomposeList(full_names)
		-- Sort the list
		say "Sorting names"
		set full_names to my qsort({Values:full_names, Weights:{1}})
		set namesList to a reference to full_names
		set dupeCount to 0
		set startCount to (count namesList)
		set theCount to 0
		set dupeCategory to category "Duplicate"
		say "Starting check of " & startCount & " contacts."
		set name1 to ""
		set name2 to "zzzz"
		repeat with aPair in namesList
			set theCount to theCount + 1
			if (theCount mod 100) = 0 then
				say "" & (startCount - theCount) & " to go."
			end if
			set aName to item 1 of aPair
			set aContact to contact id (item 2 of aPair)
			if aName is not in {" ", "", " ", "	"} then -- ignore contacts with blank address
				set name1 to aName
				set contact1 to aContact
				if name1 = name2 then -- Mark both as duplicate
					set dupeCount to dupeCount + 1
					addSecondaryCategory of me for dupeCategory onto contact1
					addSecondaryCategory of me for dupeCategory onto contact2
				end if
				set contact2 to contact1
				set name2 to name1
			end if
		end repeat
	end tell
end if
display dialog "" & dupeCount & " duplicate pairs have been flagged with the \"Duplicate\" category. 
Use the Address Book filter at upper right to isolate them for further processing."

Running stops at the line "

 set full_names to my recomposeList(full_names) 

" and the errormessage says “”<>" doesn’t understand the message “recomposeList”." (translated from German :wink: ) the same would happen with the “qsort”-line

Does anyone has a clue? In my opinion the script looks perfect and I didn’t change anything. I Use Script Editor 2.0 (v43.1), Entourage X on a MAC OS 10.3.9.

AppleScript: AppleScript D1-1.9.3
Operating System: Mac OS X (10.3.9)

KriSta,

Do you have the full script? I’m asking this because the two parts you mention are calls to subroutines. There should be more code that begins

on recomposeList(full_names)
-- do some actions
end recomposeList

It would be the same format for the qsort line.

PreTech

I guessed that it has something to do with subroutines, but I think, there is no one in the script (Sorry, I´m a newbie :|). Here is the whole script by Allen Watson (I downloaded it from the Scriptbuilder Section and I didn´t delete anything…):


-- Flag duplicate contacts; dry run for deleting dupes
(* Criteria: e-mail, first name, last name, and company must be exact match.
No other fields are checked, no merging of other fields is done. 
3/4/05: Option added to check just for duplicate first and last name, with company and address
allowed to differ.
*)
display dialog "Option 1: name, address, company must match
Option 2: Only first and last name must match." buttons {"Cancel", "Option 1", "Option 2"} default button "Option 1"
set theOption to button returned of result
tell application "Microsoft Entourage"
	-- Make sure "Duplicate" category is defined
	try
		set temp to category "Duplicate"
	on error
		make new category with properties {name:"Duplicate", color:{255, 102, 48}}
	end try
	say "Progress reports are issued every 100 contacts."
	say "Gathering data"
end tell

if theOption is "Option 1" then -- Match on four fields: name, e-mail, company
	tell application "Microsoft Entourage"
		set addrList to address of every contact
		set dupeCount to 0
		set startCount to (count addrList)
		set theCount to 0
		set dupeCategory to category "Duplicate"
		say "Starting check of " & startCount & " contacts."
		set addrListRef to a reference to addrList
		repeat with anAddr in addrListRef
			set theCount to theCount + 1
			if (theCount mod 100) = 0 then
				say (dupeCount as string) & " dupes found;" & theCount & " contacts done; " & (startCount - theCount) & " to go."
			end if
			if anAddr is not "" then -- ignore contacts with blank address
				set sameAddressGroup to find anAddr
				if (count sameAddressGroup) > 1 then
					tell sameAddressGroup
						set theFirstName to first name of item 1
						set theLastName to last name of item 1
						set cy to company of item 1
					end tell
					repeat with i from 2 to (count sameAddressGroup)
						set aContact to item i of sameAddressGroup
						tell aContact
							if theFirstName = first name and (theLastName) = last name and company = cy then
								addSecondaryCategory of me for dupeCategory onto aContact
								-- Flag the other one of the pair (might be redundant if 3 or more identical records, but oh,well!
								addSecondaryCategory of me for dupeCategory onto (get item 1 of sameAddressGroup)
								set dupeCount to dupeCount + 1
							end if
						end tell
					end repeat
				end if
			end if
		end repeat
	end tell
else -- Just check for duplicate first and last name
	tell application "Microsoft Entourage"
		set full_names to {display name of every contact, ID of every contact}
		-- Recompose the lists to produce {{name,id},{name,id},...}
		say "Continuing to process"
		set full_names to my recomposeList(full_names)
		-- Sort the list
		say "Sorting names"
		set full_names to my qsort({Values:full_names, Weights:{1}})
		set namesList to a reference to full_names
		set dupeCount to 0
		set startCount to (count namesList)
		set theCount to 0
		set dupeCategory to category "Duplicate"
		say "Starting check of " & startCount & " contacts."
		set name1 to ""
		set name2 to "zzzz"
		repeat with aPair in namesList
			set theCount to theCount + 1
			if (theCount mod 100) = 0 then
				say "" & (startCount - theCount) & " to go."
			end if
			set aName to item 1 of aPair
			set aContact to contact id (item 2 of aPair)
			if aName is not in {" ", "", " ", "	"} then -- ignore contacts with blank address
				set name1 to aName
				set contact1 to aContact
				if name1 = name2 then -- Mark both as duplicate
					set dupeCount to dupeCount + 1
					addSecondaryCategory of me for dupeCategory onto contact1
					addSecondaryCategory of me for dupeCategory onto contact2
				end if
				set contact2 to contact1
				set name2 to name1
			end if
		end repeat
	end tell
end if
display dialog "" & dupeCount & " duplicate pairs have been flagged with the \"Duplicate\" category. 
Use the Address Book filter at upper right to isolate them for further processing."

-- addSecondary Category for the Item
to addSecondaryCategory for theCat onto theItem
	tell application "Microsoft Entourage"
		set c to the category of theItem
		if {theCat} is not in c then
			copy theCat to end of c
			set the category of theItem to c
		end if
	end tell
end addSecondaryCategory