Section 18.2. Standard Commands


18.2. Standard Commands

The standard commands are basic events that should be implemented by any scriptable application. The only standard command implemented by AppleScript itself is count (with strings, lists, and records; see Chapter 13).

count

Syntax

 count object[each class] count every class of object count class-plural of object 

Description

Reports the number of class elements of object.

The count command is implemented in an unusual way. The class represents the element that is to be counted; it is optional, and most users prefer the second or third formulation if it is to be specified. (So, one tends to say "count items of L" rather than "count L each item.") If it is not specified, then it is up to the target to supply a default element and count it. Users tend to be unconscious of this fact. For example, when you say "count s," where s is a string, you're probably not aware that AppleScript is reinterpreting this as "count s each character." That's because character is the default element for a string; you could also specify a different element ("count words of s"). This syntax is sometimes the cause of misunderstandings, especially when talking to some scriptable application. See "Repeat With... In" in Chapter 19.




AppleScript. The Definitive Guide
AppleScript: The Definitive Guide, 2nd Edition
ISBN: 0596102119
EAN: 2147483647
Year: 2006
Pages: 267
Authors: Matt Neuburg

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net