Searching for AppleScript references or object model

A

Aries Decimal

I've been looking for official (or unofficial) documentation on the
object model of Entourage 2004 for use with AppleScript. I notice that
Microsoft's site has downloadable reference documents for the other
Office 2004 applications, but not Entourage. Anyone have any pointers?

Thanks!

~Ad
 
M

matt neuburg

Aries Decimal said:
I've been looking for official (or unofficial) documentation on the
object model of Entourage 2004 for use with AppleScript. I notice that
Microsoft's site has downloadable reference documents for the other
Office 2004 applications, but not Entourage.

The dictionary documents the object model. What is that you'd like to
know that it doesn't tell you? m.

PS There's an immense number of example scripts on the Internet;
Entourage is a very popularly scripted apps.
 
A

Aries Decimal

Yes, I've been looking at the dictionary and some example scripts.
They've indeed been helpful. I was just hoping for some more
"official" reference document, as there is for Excel and Word.

While I've got your attention, here's a quickie I couldn't get to work
for the life of me:

set matchingAccounts to (every IMAP account whose email address
starts with "[email protected]")

This always results in an empty list (even when the email address
matches, of course).

I ended up having to do this, instead:

repeat with thisAcct in (every IMAP account)
if email address of thisAcct starts with
"[email protected]" then
set acctMatch to thisAcct
end if
end repeat

Any ideas?
 
M

matt neuburg

Aries Decimal said:
Yes, I've been looking at the dictionary and some example scripts.
They've indeed been helpful. I was just hoping for some more
"official" reference document, as there is for Excel and Word.

While I've got your attention, here's a quickie I couldn't get to work
for the life of me:

set matchingAccounts to (every IMAP account whose email address
starts with "[email protected]")

This always results in an empty list (even when the email address
matches, of course).

set matchingAccounts to (get every IMAP account where its email address
starts with "[email protected]")

But how do I know? Is it because I read my own book? No way. It's
because I banged away at it. You have no way on earth to know what's
implemented except by trying. That's AppleScript. And welcome to it! :)
m.
 
A

Aries Decimal

Hey, thanks a bundle!! And this is exactly what I'm talking about wrt
"official" documentation...

Care to share some light on what the semantic difference is between
"whose" and "where its"??

ad.
 
P

Paul Berkowitz

There's normally no difference. But AppleScript can get confused when you
reference a property ('email address') which also happens to be a class in
its own right. (If you look in the Entourage Contact Suite you'll find the
class 'email address': it's used as an element of 'contact'.) It assumes the
class, and returns {} because the class 'email address' doesn't start with
"[email protected]" (nor anything else) - it stumbles. In order to make things
clear, 'it' or 'its' will always specify to which containing object (your
IMAP accounts) you're referring. Since 'where its' is a synonym for 'whose'
which use just such an 'its', it does the job.

You also need to use the same construction, for the same reason, when
checking for a category of any object (message, folder, contact, group,
event, task, note, project - anything that can have categories), in a whose
clause, since 'category' is also a class:

get every contact where its category contains {category "Work"}

'whose' doesn't work here either (always returns {}).

I think that's all the mixed classes/properties. The Entourage developers
had learned enough from this problem that when they created the 'project'
class for Entourage 2004, they made the property 'project list' instead of
simply 'project'. Unfortunately it's too late now to go back and do the same
for 'category list'.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
A

Aries Decimal

Thanks for the great explanation! Now I don't feel quite a dumb as I
did last night trying to figure the problem out. =)

ad.
 
M

matt neuburg

Paul Berkowitz said:
"[email protected]" (nor anything else) - it stumbles. In order to make things
clear, 'it' or 'its' will always specify to which containing object (your
IMAP accounts) you're referring. Since 'where its' is a synonym for 'whose'
which use just such an 'its', it does the job.

Just to clarify further, AppleScript is much stupider than that. As my
book explains (p. 202), "where" and "whose" are pure synonyms. You could
do without "where" completely. Thus, while "whose" does not work because
of the property/class bug so brilliantly described by Paul, "whose its"
does. So, the fix is not the switch from "whose" to "where its"; the fix
is simply the addition of "its", which resolves to the property instead
of the class. The switch to "where" is just an optional move to satisfy
your sense of English style. m.
 
A

Aries Decimal

One of the things that has always bugged me about VisualBasic and
VBScript is its 'looseness' (in VB there's the case of parentheses
around the arguments to a procedure). Although it's very nice to see
how English-like AppleScript can be, I wonder if all its synonyms might
not be more troublesome than helpful.

Another question (while I have the attention of you two brilliant
guys...) -- unless I'm missing something, there doesn't seem to be any
sort of event handling provided by the Entourage object model. This
surprises me since such things are so common in Microsoft's Windows
products. Something like 'onMessageSend' would be extremely handy. Any
ideas why this is?

aD.
 
M

matt neuburg

Aries Decimal said:
One of the things that has always bugged me about VisualBasic and
VBScript is its 'looseness' (in VB there's the case of parentheses
around the arguments to a procedure). Although it's very nice to see
how English-like AppleScript can be, I wonder if all its synonyms might
not be more troublesome than helpful.

I certainly argue in my book that both the synonyms and the
English-likeness are more troublesome than helpful. Other users don't
agree.
Another question (while I have the attention of you two brilliant
guys...) -- unless I'm missing something, there doesn't seem to be any
sort of event handling provided by the Entourage object model. This
surprises me since such things are so common in Microsoft's Windows
products. Something like 'onMessageSend' would be extremely handy. Any
ideas why this is?

Rules are a kind of event handling, since you can run a script as part
of a rule. Also, Entourage has a scripts menu, so you could store a
script there that sends the current message and then does whatever else
it is you'd like done. Paul will probably have more (and better)
suggestions. m.
 
P

Paul Berkowitz

One of the things that has always bugged me about VisualBasic and
VBScript is its 'looseness' (in VB there's the case of parentheses
around the arguments to a procedure). Although it's very nice to see
how English-like AppleScript can be, I wonder if all its synonyms might
not be more troublesome than helpful.

After a while, you get to know them. Some people find it helps just to stick
to one variation - there's nothing stopping you from doing that. I find that
a few of the synonyms seem so overdone (they seem to "try too hard") so I
avoid those. Otherwise, I like the degree of flexibility they offer, on
balance. You just need to learn _right away_ that the fact that there can be
three "right ways" rather than just one "right way" does NOT mean that
"anything works" - it doesn't. Very occasionally you'll run into someone who
thinks that they can just write ordinary English sentences and it will just
work - it won't. (And, yes, this mistaken notion is an unfortunate result of
AppleScript wanting to appear "user friendly", taken to extremes.) But you
don't have that problem. You'd prefer that there be just one right way, and
you'd learn it. You can still act as if that's true, if you wish.

Nevertheless, all in all, I still believe that the "Englishness" of
AppleScript makes it understandable and approachable to people learning
their first programming language with the aim of "getting something done"
rather than studying computer science. It's mostly only people who have long
passed that hurdle, especially those coming to AS from other languages, who
wish that AS was stricter an more like other languages.
Another question (while I have the attention of you two brilliant
guys...) -- unless I'm missing something, there doesn't seem to be any
sort of event handling provided by the Entourage object model. This
surprises me since such things are so common in Microsoft's Windows
products. Something like 'onMessageSend' would be extremely handy. Any
ideas why this is?

There are almost _no_ applications which have event handling in AppleScript
(outside of writing your own AppleScript Studio application, of course).
Technically, it is possible - it's called making an application
"attachable". I know only of a couple script editors which are attachable.
When I asked the then-Entourage lead developer, who also implemented
Entourage's scriptability, why you couldn't intercept the "Send" button to
make true "outgoing rules" (rather than "outgone rules") he said it was a
conscious decision. Attachability - event handling - would permit really bad
viruses from being developed. And of course it is indeed the event-driven
auto-macros in the other Office apps which permit viruses to have done
damage there, especially auto-open and auto-startup macros. (Even now, it's
the one big difference in the new 2004 AppleScript of Word, Excel,
PowerPoint: no event handling, no auto macros possible in straight
AppleScript, as opposed to VBA.)

As Matt says, mail rules are a special case of event handling (the event
being a new message arriving, or just sent), and schedules can be set to run
At Startup and On Quit, with both rules and schedules capable of running
scripts. That makes Entourage, and other email clients which have filters
too, _more_ event-driven than any other apps I know except those scriptable
script editors.


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
P

Paul Berkowitz

Just to clarify further, AppleScript is much stupider than that. As my
book explains (p. 202), "where" and "whose" are pure synonyms. You could
do without "where" completely. Thus, while "whose" does not work because
of the property/class bug so brilliantly described by Paul, "whose its"
does. So, the fix is not the switch from "whose" to "where its"; the fix
is simply the addition of "its", which resolves to the property instead
of the class. The switch to "where" is just an optional move to satisfy
your sense of English style. m.

I'd forgotten that (I must have read it in your book, but never taken it
in). It almost makes sense then to use 'where', rather than 'whose', as a
habit and a reminder to oneself that 'its' is missing unless you specify it.
The English word 'whose' really sort of implies 'where its' - it's
possessive - whereas the bare 'where' doesn't.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
A

Aries Decimal

Thanks to both of you for your well-written answers. They've been very
enlightening. Now I guess I'll go off to buy some books... =)

aD.
 
Top