Re: Identifying app by creator code??
Re: Identifying app by creator code??
- Subject: Re: Identifying app by creator code??
- From: Jolly Roger <email@hidden>
- Date: Wed, 03 Jan 2001 15:38:45 -0600
- Replyto: email@hidden
on 1/3/2001 2:31 PM, Michael Kern wrote:
>
The problem is the script won9t compile this way. I keep getting an error
>
at the 2nd to last line 3make...2 on the word window.
You've struck on a problem that has plagued us for a long time. Welcome to
AppleScript. :)
Since you are using Outlook Express terminology outside of a standard "tell
application "Outlook Express"" block, AppleScript has no idea which
application owns the terminology, and therefore cannot resolve the
terminology to compile the script.
Luckily, there are ways around this problem. You can aleve this problem in
two ways:
METHOD 1 (the "double-tell" method):
This method is the easiest to do; but can still result in the "Where is
application xxx" dialog under certain circumstances; so I find it
unsatisfactory. What you do is add another tell block inside of your "tell
appOE" block. The second tell block should be a standard "tell application
xxx" so that AppleScript can resolve the application and terminology. This
method would look like this:
-- begin script
set ename to "Michael"
set eaddress to "email@hidden"
set creaType to "MSNM" -- Outlook's creator code
tell application "Finder" to open application file id creaType
--the following sets Outlook Express to the variable appOE as an application
tell application "Finder" to the first process whose creator type is
(creaType as type class)
set appOE to the result as +class psn ;
tell appOE
tell application "Outlook Express"
make new draft window with properties {to recipients:ename & "<" &
eaddress & ">"}
end tell
end tell
-- end script
Again, in certain situations, this will still allow AppleScript to ask the
user to locate the application in question. I've had it happen to me
before, and have since learned a better way to handle the problem.
METHOD 2 (the "raw event code" method):
This method is a little harder to do, but will make it so that no matter
what, your script will never ask the user to locate the application in
question.
This method involves obtaining the "raw event codes" for the corresponding
terminology, and using them in the script in place of Outlook Express
terminology. That way Applescript does not need to resolve OE terminology,
and will therefore compile the script.
This method does not require you to use a standard tell block, and therefore
will not result in the "Where is application xxx" message you are trying to
avoid.
To obtain the "raw event codes" you can use the freeware script editor
Smile. Smile has a "tell..." menu command that allows you to specify a
target application for a script window. Once the script window is targeted
to an application (in your case OE), you compile (check syntax) the script.
Then you choose another menu command called "Copy Translate", which
translates the terminology into raw event codes, and places them on the
clipboard. You may then paste those raw event codes into a non-standard
tell block and they will compile.
Notice how the following script uses raw event codes in place of OE
terminology:
-- begin script
set ename to "Michael"
set eaddress to "email@hidden"
set creaType to "MSNM" -- Outlook's creator code
tell application "Finder" to open application file id creaType
--the following sets Outlook Express to the variable appOE as an application
tell application "Finder" to the first process whose creator type is
(creaType as type class)
set appOE to the result as +class psn ;
tell appOE
make new +class cDfW; with properties {+class toSt;:ename & "<" &
eaddress & ">"}
end tell
-- end script
Method 2 is my preferred method. I've been using it for a couple years now.
Other methods I have tried failed in one way or another. This method just
works.
Note: the list server will mangle the script a bit. The + character should
be double left brackets (like <<), and the ; character should be double
right brackets (like >>).
HTH
JR