Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1007207 // Export AI concepts to server (old)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5619L/39K/131K).

!7

sS aiConcepts = #1006463;
sS exportSnippetID;

p {
  pcall-messagebox {
    try {
      doExport();
    } catch e {
      if (containsIC(str(e), "Not your snippet")) {
        exportSnippetID = null;
        save("exportSnippetID");
        doExport();
      } else rethrow(e);
    }
  }
}

svoid doExport {
  useDataDirOf(aiConcepts);
  S text = loadConceptsStructure(aiConcepts);
  if (match("exportable=f", text)) fail("Non-exportable concepts found");
  print(javaTokWordWrap(text));
  print("Size: " + l(utf8(text)));
  print();
  load("exportSnippetID");
  if (empty(exportSnippetID)) {
    infoBox("Creating a snippet for you...");
    exportSnippetID = createSnippet(text, "AI Concepts from " + computerID(), 53);
    infoBox("Your snippet ID: " + exportSnippetID);
    save("exportSnippetID");
  } else {
    S oldMD5 = getSnippetMD5(exportSnippetID);
    S newMD5 = md5(text);
    if (eq(oldMD5, newMD5))
      infoBox("Snippet " + exportSnippetID + " already up to date!");
    else {
      infoBox("Updating snippet: " + exportSnippetID);
      editSnippet(exportSnippetID, text);
      S actualMD5 = getSnippetMD5(exportSnippetID);
      if (eq(actualMD5, newMD5))
        infoBox("Export to " + exportSnippetID + " complete (" + n(lUtf8(text), "bytes") + ").");
      else if (eq(actualMD5, oldMD5))
        infoBox("Export failed for unknown reason");
      else
        infoBox("Hm. Export did something, but MD5 mismatch occurred.");
    }
  }
}

Author comment

Began life as a copy of #1007205

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv

No comments. add comment

Snippet ID: #1007207
Snippet name: Export AI concepts to server (old)
Eternal ID of this version: #1007207/14
Text MD5: db138a7f25593533c6954890653492c5
Transpilation MD5: c9c46fc1579652df818001cd37b34c5a
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-27 00:05:08
Source code size: 1515 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 513 / 596
Version history: 13 change(s)
Referenced in: [show references]