On Jan 02, 2011, at 22:44, Joshua Whalen wrote: the script seems to choke on extracting the data I want from the list. ______________________________________________________________________
Hey Joshua,
I think I'd start with a little simplification:
tell application "Mail" set theMessages to messages of inbox whose read status is false and subject contains "[Gizmo] Voicemail from:" end tell
This gets you a list of message specifiers, and you can then go to town extracting the information you want.
set messageSubjectList to {} set messageFromList to {} tell application "Mail" set theMessages to messages of inbox whose read status is false and subject contains "[Gizmo] Voicemail from:" if theMessages ≠ {} then repeat with ndx in theMessages tell ndx set end of messageSubjectList to its subject set end of messageFromList to sender end tell end repeat {messageSubjectList, messageFromList} end if end tell
Note that this line produces a list:
subject of messages of inbox whose read status is false
So you don't need this line:
set theMessages to a reference to every text item of the result as list
When I parse through lists and text in Applescript my preferred tool is the Satimage.osax (url not provided due to technical reasons related to my bleeping domain carrier). The SIO integrates textual 'find/replace' and regular _expression_ 'find/replace' very neatly into Applescript (amongst many other goodies).
set textToSearch to " abbot abbotcy abbotnullius abbotship abbreviate abbreviately abbreviation abbreviator abbreviatory abbreviature"
set theResult to find text "abb?.+(n|p).*" in textToSearch ¬ case sensitive false ¬ regexp true ¬ whole word false ¬ all occurrences true ¬ with string result
--> Result:
{ "abbotnullius", "abbotship", "abbreviation" }
Something like this is a breeze:
set aList to {"Christopher Stone", "George Wellington", "Christopher Columbus"}
set aList to join aList using linefeed
set theResult to find text ".*chris.*" in aList ¬ case sensitive false ¬ regexp true ¬ whole word false ¬ all occurrences true ¬ with string result
--> Result:
{ "Christopher Stone", "Christopher Columbus" }
You can get pretty fancy and shell out to Perl, Python, Rugy, Tcl, ...
Or you can just use good old-timey unix shell tools like grep:
set textToSearch to " abbot abbotcy abbotnullius abbotship abbreviate abbreviately abbreviation abbreviator abbreviatory abbreviature"
set searchString to "abbot" set foundText to do shell script "egrep -i " & searchString & " <<< " & quoted form of textToSearch
--> Result:
"abbot abbotcy abbotnullius abbotship"
|