Re: I betray my ignorance - help please
Re: I betray my ignorance - help please
- Subject: Re: I betray my ignorance - help please
- From: email@hidden (Michael Sullivan)
- Date: Mon, 10 Sep 2001 09:15:36 -0400
- Organization: Society for the Incurably Pompous
>
1
>
Please could all you experts add a few comment lines to you example scripts.
>
2
>
I was just about able to drive HyperCard using the "HyperCard Script
>
Language Guide". I have not found an equivalent book for Apple
>
Script. What do you recommend?
You can download a free .pdf Applescript language guide from
www.apple.com somewhere. Probably in the developers section. If you
have trouble finding it, I can mail you a copy of mine (which might be a
year old).
A lot of folks recommended Danny Goodman's _AppleScript Handbook_ for a
book on it, and I bought that. It's pretty good.
But note that these only cover Applescript itself, and scripting the
Finder and other OS programs. Scripting applications (other than in a
very general sense) is not dealt with. For that you may need
application specific books.
The biggest problem with Applescript is that learning the *language* is
easy and only about a tenth of the battle if you want to do serious work
with it. Because next you need to know your suite of applications
script commands. That gets *much* more difficult because the
documentation available for many programs stinks to high heaven. I've
been scripting QuarkXpress now for a little over a year, and at least
half that time has been spent battling bugs/gags from pickiness of
command interpretation that is not well documented.
At least they have pretty good tech support for scripters -- someone
regularly reads this and the MacScrpt lists and answers questions, for
instance, in addition to maintaining a support address just for
scripting.
With some programs scripts don't work anything like the dictionary or
docs lead you to believe and the only resource for figuring it out is
other users/scripters like you who have put in many days of trial and
error testing. If no one who has battled your particular demon comes
forward, *you* get to spend that time beating your head against a wall,
or give up if it's not worth it.
>
3
>
Using Script Editor on clicking "Check Syntax" key words go BOLD.
>
But why do some words like "Open" that look and feel like key words
>
not go BOLD? What am I missing? The "Open" statement works so the
>
reference must be correct!! (Don't all shout at once.)
Applescript language keywords are bolded by default in SE. The
applescript language keyword set includes a lot of prepositions and
english modifiers standing in for what would be symbols in most
languages, but it's command set is quite minimal. Most commands (such
as "open" are the province of applications, not applescript itself.
they need to be in a tell block, and not language keywords but
application keywords.
A useful place to go in SE is "Edit", "Applescript Formatting".
This brings up a box that allows you to change the default formatting,
by selecting one of the syntax classes and changing it's font, size,
style or *color* by selecting from the appropriate menus (color is at
the bottom of the style menu).
I make application keywords the same color as language keywords but a
different font, and don't use anything like that color for anything else
in the document. I make my variables red and nothing else anything like
that color. When I check syntax it becomes very obvious if I have
misspelled an application or language keyword (it becomes red like my
variables), or stepped on a keyword with my variable names (it isn't
red).
Syntax coloring is tres useful, and highly recommended.
>
4
>
Are there an Apple Script equivalents to the HyperCard "Ask" and
>
"Answer" commands?
Can't help you with this one, since I don't know those commands.
A note here: Most people don't consider Applescript a replacement for
Hypercard (although combined with a DB like FMPro, you can do a lot of
what you could do with HC.
If you want to write standalone apps that only depend on AS and not on
some other scripted app, Applescript isn't really your best bet. You
can try FaceSpan or Smile, which give you some GUI elements that AS can
take advantage of, but if you don't need or want to drive existing
scriptable apps, you might be better off with something like RealBasic
than using Applescript.
On the gripping hand, AS is so very useful for workflow automation and
system administration that it's probably worth learning if you have any
prospect of using it for those functions.
Michael