Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


Count

The Count command counts the number of elements of a particular class in a container. The Finder version of the Count command is similar to the standard application command described in the AppleScript Language Guide, except that the Finder's Count command always returns a single integer.

SYNTAX
count [ each | every ] className [ ( in | of ) referenceToContainer ]
number of className [ ( in | of ) referenceToContainer ] 
PARAMETERS
className
The class name of the elements to be counted. If you use the term each or every, you can use only the singular form of
the class name. The kinds of elements that Finder objects can contain are listed in the object class definitions for each class
in Chapter 2, "Finder Objects." You must specify a class name
or the command won't work.
Class: Class identifier
referenceToContainer
A reference to the container whose elements are to be counted.
If you do not specify this parameter, the Finder counts the elements in the default target of the Tell statement (for example, the Finder application).
Class: Reference
Default value: Reference to default target of Tell statement
RESULT
Integer.

EXAMPLES
In the following example, every item of window "My World" returns a list of items. The Finder counts the items in the list.

tell application "Finder"
   count every item of window "My World"
end tell

--result: 12
The following statement is equivalent to the previous example:

tell application "Finder"
   count items of window "My World"
end tell 

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996