Adressbuch-Wähl-Script für X-Lite IP-Telefon: Brauche Hilfe

feel_x

Aktives Mitglied
Thread Starter
Dabei seit
31.07.2003
Beiträge
706
Reaktionspunkte
10
Hallau,
Ich hab hier ein kleines Script gefunden, das im Library-Ordner Adress book plugins hinterlegt wird und das vom Adressbuch aus zum Wählen von Telefonnummern via X-Lite benutzt wird.

Funktioniert prima; ich habe nur das Problem, dass ich bei vielen Telefonnummern ein +49 davor stehen habe.
Mir fehlt also einfach eine Bereinigungs-Routine, die das "+49" gegen eine "0" austauscht.. eine Routine, die alle überflüssigen Zeichen entfernt und nur die Zahlen da lässt, ist ja schon drin, die neue Funktion sollte natürlich davor ablaufen, damit das +49 noch als solches erkannt und ersetzt wird.

wer kann mir helfen?
;)


Hier das Script:
-----------------


(*
* *XLite dialer
* *The script should be placed in ~/Library/Address Book Plug-Ins (to only use it on your user account) or in
* */Library/Address Book Plug-ins (to offer it to all users on the machine).
* *
* *Right click, or Ctrl click, on a number in Address Book and the menu item
* *"Dial with XLite" will appear.
* ** *
* *The name of the XLite application might need to be changed in the script.
* *
* *The number is dialed with the default SIP server in Xlite after being cleaned of any other characters
* *than numbers.
*)



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

on action title for pers with fone
return "Dial with XLite"
end action title

on should enable action for pers with fone
if label of fone contains "fax" then return false
return true
end should enable action

on perform action for pers with fone
set theNumber to (value of fone) as string

--Erase everything that's not a digit from the phone number
set cleanedNumber to CleanTheNumber(theNumber)

--Change to the appropriate application name below
tell application "X-Lite"
dial cleanedNumber
end tell
end perform action

end using terms from


on CleanTheNumber(numToDial) -- remove punctuation from a string, leaving just the number

set theDigits to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
set cleanedNumber to ""
repeat with i from 1 to length of numToDial
set j to (character i of numToDial)
if j is in theDigits then set cleanedNumber to cleanedNumber & j
end repeat
return cleanedNumber
end CleanTheNumber

----------------
 
Irgendwie sträubt sich das Adressbuch noch etwas gegen das Scripting.
Aber etwas umständlicher als geplant geht es dann doch.

Folgendes Skript ersetzt "+49" gegen "0". Ich habe es an meinem Adressbuch getestet. Das enthielt allerdings noch nicht so viele Einträge. Aber die paar mit "+49" sind dann tatsächlich bereinigt.

tell application "Address Book"
set PeList to people
repeat with oneP in PeList
set PhV to (value of phone of oneP)
try
set PhV to item 1 of PhV
end try
if PhV starts with "+49" then
set tC to length of PhV
set tRest to characters 4 thru tC of PhV
set value of phone of oneP to ("0" & tRest) as Unicode text
end if
end repeat
end tell
 
wau, Danke für die Mühe :)

Noch eine Frage: Wie muss ich das ganze abwandeln, wenn es nicht die Einträge im Adressbuch editieren, sondern nur die jeweils ausgewählte Nummer on-the-fly bereinigt an x-lite übergeben soll?

Also: Ich will nicht die Einträge im Adressbuch ändern, sondern nur, dass beim Klicken von "dial with x-lite" die Nummer bereinigt und an X-Lite übergeben wird.
Dazu muss das umwandeln von "+49" in "0" vor die Bereinigung von Sonderzeichen direkt in mein Script.

Sorry, hab vorhin falsch ausgedrückt, was ich eigentlich will.
+49 soll im Adressbuch stehen bleiben.

feel_x
 
Die jeweils zu wählende Nummer "on the fly" ändern dürfte noch wesentlich einfacher sein. In deinem vorhandenen Skript hast du die Zeile:

set theNumber to (value of fone) as string

Danach fügst du folgendes ein:

if theNumber starts with "+49" then
set tC to length of theNumber
set theNumber to ("0" & (characters 4 thru tC of theNumber))
end if


Das sollte eigentlich funktionieren. Testen kann ich das nicht, da ich das Plug-In nicht habe.
 
Zurück
Oben Unten