Re: using terms from
Re: using terms from
- Subject: Re: using terms from
- From: Christopher Nebel <email@hidden>
- Date: Fri, 18 Jan 2002 12:25:45 -0800
On Friday, January 18, 2002, at 06:12 AM, christian vick wrote:
I searched the archives, Apple Dev, the web, the AS language guide. I
found
no 'official' or definite explanation of how it works/how the code have
to
look. Can anyone point me to the proper place?
"using terms from" is a formalized version of the old "double-tell"
trick that doesn't have "double-tell"'s problems. Specifically, it
guarantees that the static application reference won't trigger a "where
is...?" dialog when the script runs.
I'm not sure if anyone has written an article specifically on "using
terms from" technique, but Bill Cheeseman has a good article on
double-tell with some references to "using terms from" at
<
http://www.applescriptsourcebook.com/tips/tellbyvariable.html>. You'll
see constructs like this:
tell application "SpiffyWorks"
tell application appName
...
Just replace the first "tell" with "using terms from", and there you go.
I'm especially unsure about:
1) Is it still necessary on OS X if the target app is Carbon/Cocoa?
"Using terms from" is necessary because of how AppleScript finds
terminology at compile time. It has nothing to do with the OS or the
architecture of the target application. In other words, yes.
2) To define the app, what do i have to say?:
set iTunesAppName to "iTunes"
set iTunesAppName to "x:Applications:iTunes.app:Contents:MacOS:iTunes"
set iTunesAppName to alias
"x:Applications:iTunes.app:Contents:MacOS:iTunes"
Do i have to point to the app within the package?
No. You have to somehow produce an application reference just like you
do normally; a full path to the visible application "file" (whether it's
a real file or a package folder) is usually the best thing. There are a
variety of techniques for getting one; see the Sourcebook article.
3) Does 'using terms' enclose the 'tell app' statement or is it the
other
way round?
using terms from application "iTunes"
tell application iTunesAppName
--
end
end using terms from
Either way will work.
By the way: as far as I know, scripts that use "using terms from" will
work on pre-Mac OS 9 systems, though of course you can't edit them.
Saving them as run-only applets seems to give the best results.
--Chris Nebel
AppleScript Engineering