[macvoiceover] apple script

Howdy all,
Have you ever got a phone number that has characters in it? I for one can not remember the translation of the numbers to characters on the number-pad. Below is a apple script to do the job for you.

set title1 to ¬
        "Vanity phone number converter" as string
set pick to "" as string
set phone to "" as string
set counter to 0


display dialog title1 default answer the pick
copy the result as list to {the pick, the button_pressed}
set pickLen to the length of pick
repeat
        set counter to counter + 1
        set ch to item counter of pick
        set ch to characterCheck(ch)
        set phone to phone & ch
        set pickLen to pickLen - 1
        if pickLen ≤ 0 then exit repeat
end repeat
set title2 to ¬
        pick & " = " & phone
set but1 to "Copy to clipbord"
set but2 to "OK"

display dialog title2 ¬
        buttons {but1, but2} default button 1
set the bp to the button returned of the result

if bp is but1 then
        set the clipboard to title2
end if


on characterCheck(ch)
        set chars to "abcdefghijklmnopqrstuvwxyz" as string
        set fixUp to "22233344455566677778889999" as string
        set counter to 0
        set charslen to the length of chars
        
        repeat
                set counter to counter + 1
                set chr to the item counter of the chars
                if ch is chr then
                        set rchar to the item counter of the fixUp
                        return rchar as string
                end if
                set charslen to charslen - 1
                if charslen ≤ 0 then exit repeat
        end repeat
        return ch
end characterCheck

Other related posts: