Le 5 janv. 2017 à 19:53, Deivy Petrescu < email@hidden> a écrit :
On Jan 5, 2017, at 13:46 , Yvan KOENIG <email@hidden> wrote:
I edited slightly the original code and added some comments.
------------------------------------------------------------------------------------------- tell application "Contacts" tell group "Famille" set phoneNumList to value of every phone of every person end tell end tell
try phoneNumList / 0 # Issue an error message on error e # Here e is the error message (* "Impossible de convertir {{\"0645914322\"}, {}, {\"06 46 60 33 66\", \"06 45 24 95 66\"}, {\"00 (1) 605 532 66 23\"}, {}, {}, {\"06 26 19 63 14\"}, {\"02 33 66 53 15\", \"06 32 26 56 10\"}, {\"06 92 09 96 92\"}, {\"06 93 63 96 40\", \"06 26 13 60 65\"}, {}, {}, {\"03 56 96 96 04\", \"06 61 55 31 60\"}, {\"01 66 62 11 15\", \"06 10 01 05 00\"}, {\"06 93 44 06 62\"}, {\"06 55 60 09 66\"}, {\"01 65 51 29 06\", \"06 26 61 53 43\", \"01 36 56 56 50\"}, {}, {}, {\"06 46 52 05 29\"}, {\"06 49 56 09 39\"}, {\"02 33 04 93 94\"}} en type real." *) set shCMD to "echo " & quoted form of e & " | tr '\"' '\\n' | sed -En '/[0-9]/p'" # The command will extract the phone numbers from the error message set phoneNumList to paragraphs of (do shell script shCMD) end try -------------------------------------------------------------------------------------------
It behaves flawlessly.
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) jeudi 5 janvier 2017 19:44:42
May be I am missing something, but…: set t to {{"0645914322"}, {}, {"06 46 60 33 66", "06 45 24 95 66"}, {"00 (1) 605 532 66 23"}, {}, {}, {"06 26 19 63 14"}, {"02 33 66 53 15", "06 32 26 56 10"}, {"06 92 09 96 92"}, {"06 93 63 96 40", "06 26 13 60 65"}, {}, {}, {"03 56 96 96 04", "06 61 55 31 60"}, {"01 66 62 11 15", "06 10 01 05 00"}, {"06 93 44 06 62"}, {"06 55 60 09 66"}, {"01 65 51 29 06", "06 26 61 53 43", "01 36 56 56 50"}, {}, {}, {"06 46 52 05 29"}, {"06 49 56 09 39"}, {"02 33 04 93 94"}} tid(return) t as string on tid(x) set AppleScript's text item delimiters to x end tid —>"0645914322 06 46 60 33 66 06 45 24 95 66 00 (1) 605 532 66 23 06 26 19 63 14 02 33 66 53 15 06 32 26 56 10 06 92 09 96 92 06 93 63 96 40 06 26 13 60 65 03 56 96 96 04 06 61 55 31 60 01 66 62 11 15 06 10 01 05 00 06 93 44 06 62 06 55 60 09 66 01 65 51 29 06 06 26 61 53 43 01 36 56 56 50 06 46 52 05 29 06 49 56 09 39 02 33 04 93 94" Why complicate simps things? Deivy Petrescu
You missed this point: The available data is not the list, it's the error message which I highlighted i red above.
Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) jeudi 5 janvier 2017 19:58:26
|