<> <> <> <<>> <> <<>> DIRECTORY Rope USING [Equal, ROPE], SkiPatrolLog ; SkiPatrolLogImpl: CEDAR PROGRAM IMPORTS Rope EXPORTS SkiPatrolLog = BEGIN notice: PUBLIC SkiPatrolLog.ProcsRecord; YES: BOOLEAN = TRUE; NO: BOOLEAN = FALSE; ROPE: TYPE = Rope.ROPE; RopeList: TYPE = LIST OF ROPE; <> equivs: ARRAY SkiPatrolLog.Event OF RopeList = [ LIST["lockConflict", "locks", "errors", "std"], LIST["operationFailed", "opFailed", "errors", "std"], LIST["beginTransaction", "beginTrans", "trans", "transaction"], LIST["commitTransaction", "commitTrans", "commit", "trans", "transaction"], LIST["abortTransaction", "abortTrans", "abort", "trans", "transaction", "std", "errors"] ]; NameListFromRope: PUBLIC PROC [argList: LIST OF ROPE] RETURNS [names: ARRAY SkiPatrolLog.Event OF BOOL, gibberish: LIST OF ROPE] ~ { <<"names" is an array in which each element corresponds to a SkiPatrolLog event. If the value is YES (TRUE), the event was named in the ROPE list. If the value is NO (FALSE), the event was not named. However, if "argList" is empty, then all elements are returned as YES. Case is not significant. "gibberish" contains a list of those ROPEs from "argList" that weren't recognized.>> IsIn: PROC [rope: ROPE, ropeList: LIST OF ROPE] RETURNS [BOOLEAN] ~ { FOR ropeList _ ropeList, ropeList.rest WHILE ropeList # NIL DO IF rope.Equal[s2: ropeList.first, case: NO] THEN RETURN[TRUE] ENDLOOP; RETURN[FALSE] }; IF argList = NIL THEN FOR event: SkiPatrolLog.Event IN SkiPatrolLog.Event DO names[event] _ YES; ENDLOOP ELSE { matched: BOOL; -- "matched argList.first w/ a string in equivs" <> FOR event: SkiPatrolLog.Event IN SkiPatrolLog.Event DO names[event] _ NO; ENDLOOP; FOR argList _ argList, argList.rest WHILE argList # NIL DO matched _ NO; FOR event: SkiPatrolLog.Event IN SkiPatrolLog.Event DO IF IsIn[argList.first, equivs[event]] THEN names[event] _ matched _ YES; ENDLOOP; IF NOT matched THEN gibberish _ CONS[argList.first, gibberish]; ENDLOOP; }; RETURN[names, gibberish]; }; RopeFromEvent: PUBLIC PROC [event: SkiPatrolLog.Event] RETURNS [ROPE] ~ { <> RETURN[equivs[event].first] }; END. CHANGE LOG <> <> <> <> <<>>