Re: Calling an application
Re: Calling an application
- Subject: Re: Calling an application
- From: "Marc K. Myers" <email@hidden>
- Date: Sun, 11 Feb 2001 02:39:45 -0500
- Organization: [very little]
>
Date: Sun, 11 Feb 2001 13:14:38 +1300
>
Subject: Re: Calling an application
>
From: Andrew Wylie <email@hidden>
>
To: <email@hidden>
>
>
>From: "Marc K. Myers" <email@hidden>
>
>Subject: Re: Calling an application
>
> "The extra layer of "tell...end tell" with the application's name is
>
> there so the compiler can know what application it's compiling the
>
> commands for. It should have no effect at run time."
>
>
> Do you see the point now? You can have any version of the application
>
> with any name installed on the computer that's running the script and it
>
> will still work as long as the application has the right creator code.
>
>
I expected the user would be prompted to locate the application if the name
>
differed, not for AS to miraculously change it
>
I do note however this
>
method fails at 'launch application appPath' returning -1713 if the app is
>
located on a desktop other than the startup disk.
>
Is there any advantage over the simpler
>
>
----------------------------------------------------------------------------
>
tell application "Finder" to open application file id "ASRe"
>
tell application "Apple Software Restore"
>
[Do Stuff]
>
end tell
>
----------------------------------------------------------------------------
>
which doesn't fail in this situation?
Except in the situation you mention, the advantage of using the
structure I posted is that it will allow a script to run (without asking
"Where?") on a machine where the name of the application is not exactly
the same as the name of the application on the compiling machine. Also,
by launching the application rather than opening it in the Finder, it
avoids the initialization problems (splash screens, "tips of the day",
blank documents) that often accompany "running" a program.
try
tell application "Finder"
set appPath to (application file ID "ASRe") as text
set appName to name of file appPath
end tell
launch application appPath
tell application "Apple Software Restore"
tell application appName
[Do Stuff]
end tell
end tell
on error number -1728
error "\"Apple Software restore\" was not found"
end error
The way that the Finder deals with files on the desktops of non-startup
volumes is a real pain, but I've never run into the situation in a
business environment where people leave applications on the desktop.
It's just too easy to accidentally drop one in the trash! I advise all
my clients to put aliases to applications on the desktop for just that reason.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[2/11/01 2:39:37 AM]