Address Book to VOIP

Essentially, I am trying to automate all my telephone calls via my Powerbook’s Address Book in OSX, using a specific VoIP client (international calls for $0.05/Minute).

I have been making some progress with my earlier development for a dropdown within the Address Book: it now reliably adds ‘dial: 1 800 1234 1234’, to the dropdown that already shows ‘Large Type’.

So far, I can take a record of a number directly from the Address Book and send it on to another App. However, in the instance of the required VoIP client, it seems only able to receive a number using:
dial “1 800 1234 1234”

However, I need to use one script that adjusts itself according to whichever number was selected from the Address Book. Any ideas? I am currently using this script, to dynamically select the number:

tell application “VoIP_App” to activate
end

using terms from application “Address Book”
on action property
return “phone”
end action property

on action title for p with e
	return "Dial : " & value of e
end action title

on should enable action for p with e
	return true
end should enable action

on perform action for p with e
	tell application "VoIP_App"
		dial value of e
	end tell
end perform action

end using terms from

say “dialing” using “Victoria”
end

If you can help me out on this, please let me know asap! I am banging my head against the wall, seemingly only moments from the final script…

pimlicosw1@hotmail.com

Does this work (I don’t have the app to test):

using terms from application "Address Book"
	on action property
		return "phone"
	end action property
	
	on action title for p with e
		return "Dial : " & value of e
	end action title
	
	on should enable action for p with e
		return true
	end should enable action
	
	on perform action for p with e
		tell application "VoIP_App"
			activate
			dial (my clean_number((value of e) as string))
		end tell 
		say "dialing" using "Victoria"
	end perform action
end using terms from

on clean_number(the_number)
	set return_number to {}
	set the_number to (characters of the_number)
	repeat with i from 1 to (count of the_number)
		set this_char to (item i of the_number)
		if this_char is in "0123456789" then set end of return_number to this_char
	end repeat
	return return_number as string
end clean_number

Jon