Language Guide
CHAPTER 4
Commands
94 Command Definitions
This example shows another way to count the integers in the list:
count each integer in {"Yes", "No", "Maybe", 4, 5, 6}
--result: 3
In the following example, every word of document "simple" consists of
a list of words. The Scriptable Text Editor counts the words in the list.
tell application "Scriptable Text Editor"
count every word of document "simple"
end tell
--result: 12
The following statement is equivalent to the previous example:
tell application "Scriptable Text Editor"
count words of document "simple"
end tell
In the following example, referenceToObject is documents of application
"Scriptable Text Editor", which is a list of documents. The Scriptable
Text Editor counts the documents in the list.
tell application "Scriptable Text Editor"
repeat with i from 1 to (count of documents)
set the style of paragraph 1 of document i to
{outline, bold}
end repeat
end tell
NOTES
If you use the Count command on a string without specifying the class to be
counted, AppleScript counts the characters; for example,
count "This is a string"
--result: 16