<> <> <> 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 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]; }; END.