!752 static boolean activated; static long lastAction; static long idleTimeout = 5*60*1000; // 5 minutes static S data; p { load("data"); load("lastAction"); load("activated"); } synchronized answer { if (!tb()) null; // activating commands if "consider the string *" { activate(); data = m.unq(0); save("data"); ret "OK. " + someInfo(); } if "done with the string" { if (!activated) ret "Yeah i know."; data = null; save("data"); deactivate(); ret "OK, " + getName() + " deactivating."; } if (!activated || data == null) null; if (isExpired(lastAction, idleTimeout)) { deactivate(); null; } if "reverse" ret setData(reverseString(data)); if "show" ret show(); if "length" ret l(data) + " chars"; } static S someInfo() { if (data == null) ret ""; ret "Got " + l(data) + " chars."; } static void activate() { activated = true; save("activated"); lastAction = now(); save("lastAction"); } static void deactivate() { activated = false; save("activated"); data = null; save("data"); } static S setData(S s) { data = s; save("data"); ret "OK. Got " + show(); } static S show() { if (data == null) ret "No data"; S s = quote(shorten(data, 100)); if (l(data) > 100) s += " (" + l(data) + " chars)"; ret s; }