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];
ACFindTest: CEDAR PROGRAM
IMPORTS ACFind, PutGet, Rope, TEditDocumentRope
~ BEGIN
ROPE: TYPE ~ Rope.ROPE;
found: LIST OF ROPENIL;
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: ROPENIL, keys: LIST OF ROPENIL, case: BOOL] RETURNS [INT] ~ {
text: ROPENIL;
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: ROPENIL, keys: LIST OF ROPENIL, case: BOOL] RETURNS [INT] ~ {
text: ROPENIL;
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 ROPENIL, case: BOOLFALSE] RETURNS [LIST OF ROPENIL] ~ {
myRef: ACFind.Ref;
found ← NIL;
myRef ← ACFind.Create[keys, case];
[] ← ACFind.Find[myRef, text, AddToFound];
RETURN[found];
};
END.