WordCount.mesa
Copyright Ó 1988, 1992 by Xerox Corporation. All rights reserved.
Wes Irish, November 9, 1988 4:15:02 pm PST
WordCount:
CEDAR
DEFINITIONS =
BEGIN
STREAM: TYPE = IO.STREAM;
ROPE: TYPE = Rope.ROPE;
Each PROC counts the number of lines, words, and characters from the indicated source. If tokenMode is FALSE (the default) then words are defined to be non-white-space delimited by white-space. If tokenMode is TRUE then words will be delimited in a fashion similar to Cedar tokens.
CountStream: PROC [s: STREAM, tokenMode: BOOL ¬ FALSE] RETURNS [lines, words, characters: INT];
CountSelection: PROC [tokenMode: BOOL ¬ FALSE] RETURNS [lines, words, characters: INT];
CountRope: PROC [r: ROPE, tokenMode: BOOL ¬ FALSE] RETURNS [lines, words, characters: INT];
CountFile:
PROC [file:
ROPE, tokenMode:
BOOL ¬
FALSE]
RETURNS [lines, words, characters:
INT];
Will return [-1, -1, -1] if there is trouble opening the file.
END.