Le 16/01/2014 à 10:28, Marion Dickten < email@hidden> a écrit : Hello all,
This is not a question but rather a request to all people in the list who occasionally teach other people how to use AppleScript. I've scratched my head a long time over this issue, and after reading the thread "Save as a web archive" I can see that other people also have the problem I have seen.
Some years ago I taught a two-day course on AppleScript. The first day focused on AppleScript itself, the second day went into AppleScripting QuarkXPress and InDesign. The participants had been using AppleScript for a long time, scripting DTP applications by trial and error, and felt a strong need to have a systematic introduction.
After the first day one of the participants came up to me and said: "Wow, we finally understood AppleScript! We all used a book to teach ourselves so far and it was all so confusing-- those nouns and verbs and things, and it simply doesn't add up." Then *I* was confused, because I had never seen "nouns" and "verbs" except in Dictionaries (where they never helped, so I disregarded them completely). So the man told me that in the book they used the whole of AppleScript was explained in terms of nouns and verbs, and they found that a very complicated approach.
The approach I used without thinking even once about it was the approach suggested by Matt Neuburg in his Definitive Guide. It boils down to three rules.
1. Practically everything is an object. (The word "object", after all, means something like "thing", so this makes sense.) Examples are "document"s, "file"s, "disk"s, "window"s, you name it.
2. Objects can take certain messages and do something then. You tell an object to do something by saying "tell". (Easy.) In order to enable the object to understand the message, you need to supply all necessary information. This information consists of objects (see rule 1), and is called "Parameters". They may be included in brackets or marked as such by certain keywords, such as "as" or "in". These keywords are sometimes called "prepositions" (because that's what they are, they are written in front of the info supplied).
3. Objects may contain (or own, depending on how you want to think of it) other objects. A "document", for instance, contains "pages". (Easy.) If you want to send a message to an object contained in another object, you address the inner object by saying "of" (or "'s"). For instance, you say "page 1 of document 1".
When you have digested those three rules, AppleScript is, in my experience at least, fully understandable. All ramifications of AppleScript arise out of these rules.
The problem about the "noun" and "verb" metaphor is that both words are used in everyday language and are used in AppleScript to mean some aspects specific to the programming language *not* identical with the everyday meaning. This is the core of the problem. It is much better to avoid that metaphor altogether since it makes comprehension more difficult than the use of the object-message-metaphor which is more suitable to programming. AppleScript's origins were the ambitious idea to write a programming language working exactly like a natural language, and that has failed. This, in my opinion, should have been admitted, and the inadequate metaphor should have been completely dropped at least a decade ago.
Alex Zavatone in his post about "Save as a web archive" writes that he thought "as" is a "verb". He never thought "as" is a verb, of course. He was speaking about AppleScript classification of keywords, and his sentence is a perfect example of the confusion that classification causes. It simply doesn't fit.
Marion
As I wrote, Alex made an error (nobody's perfect) which introduced confusion.
as is not a verb, it's an adverb. In AppleScript language I didn't found the word adverb. In fact, as is the coercion operator (see page 34 in the 2013-10-22 AppleScript Language Guide)
My point of view is that a good rule is to remember that AppleScript is not English. It's just a programmation language which — for the best and for the worst — use English words.
Doug McNutt, an old member of this list often used this kind of signature :
Applescript syntax is like English spelling: Roughly, but not thoroughly, thought through.
When something seems obscure, the first thing to do it to return to the holy book : AppleScript Language Guide. If things remain obscure, don fight against wind mills, ask in a forum like this one. I will not give names but there is a sufficient number of experts in this forum to allow us to hope that somebody will be able to bring the wanted light.
Yvan KOENIG (VALLAURIS, France) jeudi 16 janvier 2014 14:13:41
|