Re: List processes problem
Re: List processes problem
- Subject: Re: List processes problem
- From: Michelle Steiner <email@hidden>
- Date: Wed, 3 Jan 2001 14:03:01 -0800
On 1/3/01 1:37 PM, steve <email@hidden> wrote
>
Here's what's happening...
>
>
If the process is running, everything is ok. But if the process isn't
>
running, that's when it chokes. To test in a simplistic form, I wrote this:
[snip]
>
What happens here is straightforward. If I enter Launcher into the dialog, I
>
get a dialog that says "Process Launcher is running". If you close Launcher
>
then run the script I get "Finder got an error: Can't get process Launcher"
>
-1728.
>
>
To combat this, I changed my script to test for an error. If it encountered
>
one, I can assume (for now) that the process is not running:
[...]
>
I don't know how robust this is yet and I will test it more thoroughly, but
>
what I can do is re-launch all necessary apps on error.
>
>
What do you think about this? Not so efficient, is it?
It looks like the on error is the only way to do it; however, you do not
have to create a list of running processes and test for membership in it,
because the error is generated before it can do the comparison.
Look at this fragment:
set a to "script editor"
set b to "aaa"
tell application "Finder"
try
{process a, process b}
display dialog "both running"
on error
display dialog "something's not running"
end try
end tell
It will display the error dialog; if you replace "aaa" with the name of a
runnning application, it will display "both running". (Assuming that
Script Editor is runnning when you run the script). You can use the
error codes to determine which process is not running, and the error
handler can then launch the application.
Of course, if there's more than one not running, it will run only one, so
maybe running the entire bunch would be easier.
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | Hard as it may be to believe, my |
| email@hidden | life has been based on a true story. |
----------------------------------------------------------------------