Lingo Dictionary > L-N > number (words) |  |

number (words)

Syntax

    the number of words in chunkExpression

Description

Chunk expression; returns the number of words in the chunk expression specified by `chunkExpression`.

Chunk expressions are any character, word, item, or line in any container of characters. Containers include field cast members and variables that hold strings, and specified characters, words, items, lines, and ranges in containers.

To accomplish this functionality with text cast members, see `count`.

Note: The `count()` function provides a more efficient alternative for determining the number of words in a chunk expression.

Example

This statement displays in the Message window the number of words in the string "Macromedia, the multimedia company":

    put the number of words in "Macromedia, the multimedia company"

The result is 4.

Example

This handler reverses the order of words in the string specified by the argument `wordList`:

    on reverse wordList
    	theList = EMPTY
    	repeat with i = 1 to the number of words in wordList
    		put word i of wordList & " " before theList
    	end repeat
    	delete theList.char[thelist.char.count]
    	return theList
    end

See also

`count()`, `number (characters)`, `number (items)`, `number (lines)`, `word...of`