Re: Multi application support in single script [part 2 of 2]
Re: Multi application support in single script [part 2 of 2]
- Subject: Re: Multi application support in single script [part 2 of 2]
- From: Kai <email@hidden>
- Date: Sat, 28 Jun 2003 15:23:26 +0100
in part 1 of this message, I wrote:
>
[please also see part 2 of this message...]
Here's another thought. Instead of storing a list of every email app (in the
property 'appAliasList'), you might consider using 'choose from list' during
the initial run - to ask the user to choose a default app. This could then
be assigned to a property like, say, 'defaultApp' instead. (Just ask if you
want more specific advice about this approach.)
However - back to your original script:
>
> on run {}
>
> set messageList to {}
>
> if ProcessNamedIsRunning("Mail") then
>
> set messageList to GetMailList(messageList)
>
> end if
>
> if (count of messageList) = 0 then
>
> if ProcessNamedIsRunning("Microsoft Entourage") then
>
> set messageList to GetEntourageList(messageList)
>
> end if
>
> end if
>
> if (count of messageList) = 0 then
>
> if ProcessNamedIsRunning("Eudora") then
>
> set messageList to GetEudoraList(messageList)
>
> end if
>
> end if
>
> if (count of messageList) = 0 then
>
> if ProcessNamedIsRunning("Mailsmith") then
>
> set messageList to GetEudoraList(messageList)
>
> end if
>
> end if
>
> ProcessMessages(messageList, true)
>
> end run
>
>
>
> on ProcessNamedIsRunning(processName)
>
> tell application "System Events"
>
> return (exists application process processName)
>
> end tell
>
> end ProcessNamedIsRunning
>
>
>
> on GetMailList(msgList)
>
> tell application "Mail"
>
> -- Do stuff
>
> end tell
>
> return msgList
>
> end GetMailList
>
>
>
> -- [similar handlers for Entourage, Eudora and Mailsmith also included]
To be honest Christian, I couldn't see the purpose of initially passing the
value of 'msgList' to an email handler - since it's just an empty list. I
may have misunderstood exactly what you're trying to do here, but I
dispensed with it anyway in this suggested alternative:
-------------------------------------------------------
(Any wrapped lines abutting the left edge of the window
should be reconnected to the end of the previous line)
-------------------------------------------------------
--===========================================================
property appList : {"Mail", "Microsoft Entourage", "Eudora",
"Mailsmith"}
to processMessages(messageList, someBoolean)
-- do stuff
end processMessages
to getMessageList(appName)
if appName is "Mail" then
getMailList(appName)
else if appName is "Entourage" then
getEntourageList(appName)
else if appName is "Eudora" then
getEudoraList(appName)
else if appName is "Mailsmith" then
getMailsmithList(appName)
end if
end getMessageList
to getMailList(appName)
using terms from application "Mail"
tell application appName
set msgList to anything -- modify as required
-- do any other stuff
end tell
end using terms from
msgList
end getMailList
-- (add similar 'getList' handlers for Entourage, Eudora, Mailsmith,
etc.)
on run
tell application "System Events" to set appName to (first process
whose name is in appList)'s name
if (count appName) is 0 then display dialog "No supported email
application is running." buttons {"Cancel"} default button 1 with icon 0
processMessages(getMessageList(appName), true)
end run
--===========================================================
Since I'm currently cobbling these suggestions together on an older
system[1], there's a chance that the above may error on your machine. If it
does, you might try changing the run handler to something along these lines:
--=================
on run
set appName to ""
try
tell application "System Events" to set appName to (first
process whose name is in appList)'s name
end try
if (count appName) is 0 then display dialog "No supported email
application is running." buttons {"Cancel"} default button 1 with icon 0
processMessages(getMessageList(appName), true)
end run
--=================
[1] (No System Events, no Mail, no Entourage, no Eudora, no Mailsmith... no
hope of getting it right.) :-)
--
Kai
_______________________________________________
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.