// add latest include static S addStdFunction() { loading { ret addStdFunction(findLatestInclude().id, true); } } static S addStdFunction(bool realEdit) { ret addStdFunction(findLatestInclude().id, realEdit); } static S addStdFunction_1006654; static S addStdFunction(S snippetID, bool realEdit) { loading { LS names = findFunctionDefsAtCurlyLevel(0, loadSnippet(snippetID)); printStructure("Functions defined in " + snippetID + ": ", names); if (empty(names)) ret "No functions found in " + snippetID; S name = firstNotStartingWith(names, "_onLoad_"); if (empty(names)) ret "No definable functions found in " + snippetID; if (addStdFunction_1006654 == null) addStdFunction_1006654 = loadSnippet(#1006654); Map map = parseStdFunctionsList(addStdFunction_1006654); S text = loadSnippet("#761"); map.putAll(parseStdFunctionsList(text)); S def = map.get(name); S result = ""; if (def == null) { print(result = "Defining " + name + "."); S newText = addToStdFunctionsList(text, name, snippetID); print(); print(unidiff(text, newText)); if (!realEdit) print(result += " Not editing (test mode)."); else { editSnippet("#761", newText); triggerTranspilerDirty(); print(result += " Edited #761. Now " + countLines(newText) + " lines - " + n(l(map)+1, "total function") + "!"); } } else { print(result = "Function " + name + " already defined as " + def); if (sameSnippetID(def, snippetID)) print("Exiting."); else print("Will not redefine as " + snippetID + "."); } ret result; } }