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

74
LINES

< > BotCompany Repo | #1001201 // Program Runner Bot (for analysing the results of program runs)

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

Libraryless. Compilation Failed (1084L/8K).

!747

m {
  static S testProgram = "#1001200"; // get PATH variable
  
  static Class programClass;
  static S state;
  static Throwable exception;
  
  static DialogIO helper;
  
  p {
    makeAndroid("Program Runner Bot");
    runProgram(testProgram);
    helper = findBot("Helper Bot");
    print("Helper found: " + helper != null);
  }
  
  static class Defer {
    S id;
    S answer;
    
    *() {
      id = makeRandomID(6);
      defers.put(id, this);
    }
    
    public String toString() {
      return "Question deferred. ID: " + id;
    }
  }
  
  static new TreeMap<S, Defer> defers;

  static synchronized S answer(S s) {
    new Matches m;
    
    if (match3("get deferred answer *", s, m)) {
      S id = unquote(m.m[0]);
      Defer d = defers.get(id);
      if (d != null)
        return d.answer != null ? d.answer : "No answer yet.";
      else
        return "Defer ID " + id + " not found...";
    }
    
    if (helper != null) {
      new Defer defer;
      helper.sendLine("Please advise, defer id: " + defer.id + ", command: " + quote(s));
      return defer.toString();
    }
    
    return null;
  }
  
  static void state(S s) {
    state = s;
    print(s);
  }
  
  static synchronized void runProgram(S programID) {
    exception = null;
    state("Loading "+ programID);
    programClass = hotwire(programID);
    state("Calling main");
    try {
      callMain(programClass);
    } catch (Throwable e) {
      exception = e;
      state("main done with exception");
    }
    state("main done without exception");
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001201
Snippet name: Program Runner Bot (for analysing the results of program runs)
Eternal ID of this version: #1001201/1
Text MD5: f69a09b661724ed7e6e36c367a0ec850
Transpilation MD5: 567187ba836ff7d2de210a816a5fde6d
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-09-30 18:45:19
Source code size: 1630 bytes / 74 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 581 / 634
Referenced in: [show references]