!752 !include #1004681 // Concepts !include #1004924 // DB Classes p { loadAndAutoSaveConcepts(); print("Lines: " + l(conceptsOfType("Line"))); makeBot("Boolean Flag Test."); final L exposedMethods = concatLists( exposedDBMethods, ll("xfindLine")); makeBot("Boolean Flag DB.", new O { S answer(S s) { ret exposeMethods(s, exposedMethods); } }); } static TheFlag getFlag() { ret unary(TheFlag.class); } synchronized answer { TheFlag flag = getFlag(); Line line = findWhere(list(Line.class), "text", s); if (line == null) line = new Line(s); Interpretation ip = line.interpretation.get(); if (ip == null) ret "No interpretation for " + quote(s); if (ip instanceof NotForMe) ret "Talk to the hand"; if (ip instanceof GetFlag) ret yn(flag.set); if (ip instanceof FlagOn) { if (flag.set) ret "Flag already set!"; flag.set = true; change(); ret "OK, flag set."; } if (ip instanceof FlagOff) { if (!flag.set) ret "Flag already cleared!"; flag.set = false; change(); ret "OK, flag cleared."; } } static PassRef xfindLine(S text) { ret toPassRef(findWhere(list(Line.class), "text", text)); }