|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | +<!-- Article ID: 65 - Extracted from develop-1996 --> |
| 5 | +<!-- on 2025-01-18 by Giorgio Ferrara - giorgio<dot>ferrara<at>gmail<dot>com --> |
| 6 | +<!-- The content is protected by the copyright of its respective owners --> |
| 7 | +<title>December 96 - According to Script: Vocabulary Advice</title> |
| 8 | +<link href="../common/styles/main.css" rel="stylesheet" type="text/css"> |
| 9 | +</head> |
| 10 | +<body> |
| 11 | +<h1>According to Script:<br> |
| 12 | +Vocabulary Advice</h1> |
| 13 | +<h2>Cal Simone</h2> |
| 14 | +<p> |
| 15 | +<img src="img/320.gif" width="182 px"></img> |
| 16 | +</p> |
| 17 | +<p> |
| 18 | +One of the beautiful things about AppleScript is that it allows you to do nearly anything<br> |
| 19 | +you want in your vocabulary; however, just because it allows something doesn't mean<br> |
| 20 | +that you should do it. To help guide you, I'll regularly include miscellaneous pieces of<br> |
| 21 | +vocabulary advice in this column. This time I'll address words to avoid in your<br> |
| 22 | +vocabulary. Here are a few examples: |
| 23 | +</p> |
| 24 | +<ul> |
| 25 | +<li>Avoid using <b>object</b> as the name of a class. If you must implement an<br> |
| 26 | +abstract object class, use <b>base class</b>.</li> |
| 27 | +<li>Avoid using the word <b>of</b> in your terms. It tends to be confusing, since it's<br> |
| 28 | +used between parts of an object specification. It may not always possible to<br> |
| 29 | +avoid this, but think carefully before doing it.</li> |
| 30 | +<li>Avoid using <b>end</b> as the first word of a verb name.</li> |
| 31 | +</ul> |
| 32 | +<p> |
| 33 | +Let's look more closely at the problem with using <b>end</b>. Keep in mind that users are<br> |
| 34 | +accustomed to seeing <b>end</b> at the end of a block, and AppleScript automatically appends<br> |
| 35 | +the word <b>tell</b>, <b>repeat</b>, <b>if</b>, or the name of the handler after the word <b>end</b> if the user<br> |
| 36 | +types <b>end</b> on a line by itself. For example: |
| 37 | +</p> |
| 38 | +<pre>if the moon is blue |
| 39 | +... |
| 40 | +end [if] -- AppleScript fills in the "if"</pre> |
| 41 | +<p class="spacer"> </p> |
| 42 | +<p> |
| 43 | +If you use <b>end</b> as part of a verb name in your vocabulary, such as <b>end animation</b>,<br> |
| 44 | +users will type the word <b>end</b> by itself and expect AppleScript to fill it in. Of course,<br> |
| 45 | +this won't happen for a dictionary-defined command like <b>end animation</b>, which isn't<br> |
| 46 | +a true block construct, so it will appear that the AppleScript compiler is behaving<br> |
| 47 | +arbitrarily. |
| 48 | +</p> |
| 49 | +<pre>begin animation |
| 50 | +... |
| 51 | +end -- AppleScript doesn't fill in "animation"</pre> |
| 52 | +<p class="spacer"> </p> |
| 53 | +<p> |
| 54 | +This confusion already exists in the case of the Database suite event End Transaction. In<br> |
| 55 | +dictionaries of applications that support transactions, users find themselves having to<br> |
| 56 | +remove the word <b>transaction</b> in the phrase <b>end transaction</b> whenever they<br> |
| 57 | +recompile a script. Don't create this confusion in your vocabulary -- it's better to use<br> |
| 58 | +verb names like <b>start animation</b> and <b>stop animation</b>. Users will assume that the<br> |
| 59 | +full verb name is required. |
| 60 | +</p> |
| 61 | +<pre>start animation |
| 62 | +... |
| 63 | +stop animation</pre> |
| 64 | +<p class="spacer"> </p> |
| 65 | +<p> |
| 66 | +<b>CAL SIMONE </b> ( [email protected]) plans to include this advice in one of his future <br> |
| 67 | +According to Script columns in <i>develop</i>. We're putting it on the CD and<i>develop</i>'s Web<br> |
| 68 | +site so you won't have to wait for this valuable information.* |
| 69 | +</p> |
| 70 | +</body> |
| 71 | +</html> |
0 commit comments