Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Coerce a returned list of objects into a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce a returned list of objects into a string



Thanks Walter!

That did the trick. For anyone searching the archives I have posted my resulting code here. Thanks go to Walter for pointing me in the right direction. Let it be known that "I owe him one" ;)

--- code ---

tell application "Mail"
try
selection as application -- sure to error ;)
on error msg
my makeList(msg)
end try
end tell


on makeList(errm)
-- This function relies on Satimage OSAX to replace text
set errm to text 12 thru -21 of errm -- Take off "Can't make" and "into a application".
set msg to "+class mssg;"
set mbx to "+class mbxp;"

set errm to change msg into "message" in errm
set errm to change mbx into "mailbox" in errm
set errm to change ", " into return in errm -- make return delimited
set errm to change "{" into "" in errm
set errm to change "}" into "" in errm
end makeList

--- code ---

Matt Petrowsky


On Jul 4, 2004, at 10:32 PM, Walter Ian Kaye wrote:

At 09:33p -0700 07/04/2004, Matt Petrowsky didst inscribe upon an electronic papyrus:

I am working on a tool to archive email from Mail.app and was wondering if anyone knows if you can coerce a list of objects into their string equivalents - at least as it is returned in Script Editor.

For example, you run this

tell application "Mail"
selection
end tell

You get this.

{message 22 of mailbox "Deleted Messages" of account "ISO" of application "Mail", message 57 of mailbox "Deleted Messages" of account "ISO" of application "Mail", message 86 of mailbox "Deleted Messages" of account "ISO" of application "Mail", message 99 of mailbox "Deleted Messages" of account "ISO" of application "Mail"}

Which is the english version of all the pointers to objects. But my goal is to get this english output as a string. Such as

message 22 of mailbox "Deleted Messages" of account "ISO" of application "Mail"
message 57 of mailbox "Deleted Messages" of account "ISO" of application "Mail"
message 86 of mailbox "Deleted Messages" of account "ISO" of application "Mail"
message 99 of mailbox "Deleted Messages" of account "ISO" of application "Mail"

Anyone know if this can be done?

Hi Matt. Try this:

tell application "Mail"
try
selection as application --sure to error ;)
on error errm
set errm to text 12 thru -16 of errm
end try
end tell

You will need to parse the result as well as perform substitutions of terminology for the classes 'mssg', 'mbxp', etc.

But that's how you do it. :-)


cheers,
-Walter
still vehemently opposed to text/html and multipart/alternative email
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Coerce a returned list of objects into a string (From: Matt Petrowsky <email@hidden>)
 >Re: Coerce a returned list of objects into a string (From: Walter Ian Kaye <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.