Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AaplMike

macrumors newbie
Original poster
Nov 20, 2009
1
0
Silicon Valley, CA
Hey all.

I need a hand changing a large number of Jabber IDs within Address Book to a new server's name, so "user@hosta.mydomain.com" to user@hostb.mydomain.com". I've tested the handler separately and it works fine. The error I get is an Address Book one tho, which strikes me as odd:

Result:
error "Address Book got an error: Can’t continue splitText." number -1708

Here's what I have so far, but i'm getting an error -1708:

-- Jabber updater
-- by Mike

on splitText(delimiter, someText)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set output to text items of someText
set AppleScript's text item delimiters to prevTIDs
return first item of output
end splitText

tell application "Address Book"
repeat with thisPerson in every person
repeat with aJabber in every Jabber handle in thisPerson
if value of aJabber contains "hosta.mydomain.com" then
set theEmail to value of aJabber as text
set part1 to splitText("@", theEmail)
-- set newJabber to first item of part1 & "@hostb.mydomain.com"
-- set aJabber to newJabber
end if
end repeat
end repeat
end tell
 
It's a simple fix. Change:

set part1 to splitText("@", theEmail)

to

set part1 to my splitText("@", theEmail)

AddressBook gets the "splitText" message and doesn't know what to do with it, so it posts the error. Add "my" to tell AB that the message belongs to the script and makes sure the message gets to the right place. (At least, that's the anthropomorphic explanation; in your computer's innards, I'm sure something quite different is happening.)

mt
 
Last edited:
solution for similar case

hi, sorry to jump in the thread with something that's not exactly related to it...

but as this post is one of the few that appear in google search results, and after a lot of searching i managed to compile a mix of scripts into this working one:

script to Change or add the field "country" in all contacts of the given group
Code:
set Sgroup to "My Group"
set ADR to "My New Country"
tell application "Address Book"
	set num to count of people in group Sgroup
	repeat with n from 1 to num
		set thePerson to person n of group Sgroup
		if (count of every address of thePerson) = 0 then
			make new address at end of addresses of thePerson
			set country of first address of thePerson to ADR
			save thePerson
		end if
		if (count of every address of thePerson) ≥ 1 then
			repeat with addr in addresses of thePerson
				set country of addr to ADR
				save thePerson
			end repeat
		end if
	end repeat
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.