ACFindTest.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Dave Rumph, September 30, 1985 5:26:02 pm PDT
DIRECTORY
ACFind USING [ActionProc, Create, Find, Ref],
Rope USING [Find, ROPE],
PutGet USING [FromFile],
TEditDocumentRope USING [Create];
~
BEGIN
ROPE: TYPE ~ Rope.ROPE;
found: LIST OF ROPE ← NIL;
count: INT ← 0;
text: ROPE ← "ushers";
Null: ACFind.ActionProc ~ {};
AddToFound: ACFind.ActionProc ~ {
found ← CONS[keyFound, found];
};
Count: ACFind.ActionProc ~ {
count ← count + 1;
};
RopeTest:
PROC [file:
ROPE ←
NIL, keys:
LIST
OF
ROPE ←
NIL, case:
BOOL]
RETURNS [
INT] ~ {
text: ROPE ← NIL;
IF file = NIL THEN RETURN [0];
count ← 0;
text ← TEditDocumentRope.Create[PutGet.FromFile[file]];
FOR each:
LIST
OF
ROPE ← keys, each.rest
UNTIL each =
NIL
DO
IF Rope.Find[text, each.first, 0, case] >= 0 THEN [] ← Count[0, NIL];
ENDLOOP;
RETURN[count];
};
AcidTest:
PROC [file:
ROPE ←
NIL, keys:
LIST
OF
ROPE ←
NIL, case:
BOOL]
RETURNS [
INT] ~ {
text: ROPE ← NIL;
myRef: ACFind.Ref;
IF file = NIL THEN RETURN [0];
count ← 0;
text ← TEditDocumentRope.Create[PutGet.FromFile[file]];
myRef ← ACFind.Create[keys, case];
[] ← ACFind.Find[myRef, text, Count];
RETURN[count];
};
TestIt:
PROC [keys:
LIST
OF
ROPE ←
NIL, case:
BOOL ←
FALSE]
RETURNS [
LIST
OF
ROPE ←
NIL] ~ {
myRef: ACFind.Ref;
found ← NIL;
myRef ← ACFind.Create[keys, case];
[] ← ACFind.Find[myRef, text, AddToFound];
RETURN[found];
};