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).

1  
!747
2  
3  
m {
4  
  static S testProgram = "#1001200"; // get PATH variable
5  
  
6  
  static Class programClass;
7  
  static S state;
8  
  static Throwable exception;
9  
  
10  
  static DialogIO helper;
11  
  
12  
  p {
13  
    makeAndroid("Program Runner Bot");
14  
    runProgram(testProgram);
15  
    helper = findBot("Helper Bot");
16  
    print("Helper found: " + helper != null);
17  
  }
18  
  
19  
  static class Defer {
20  
    S id;
21  
    S answer;
22  
    
23  
    *() {
24  
      id = makeRandomID(6);
25  
      defers.put(id, this);
26  
    }
27  
    
28  
    public String toString() {
29  
      return "Question deferred. ID: " + id;
30  
    }
31  
  }
32  
  
33  
  static new TreeMap<S, Defer> defers;
34  
35  
  static synchronized S answer(S s) {
36  
    new Matches m;
37  
    
38  
    if (match3("get deferred answer *", s, m)) {
39  
      S id = unquote(m.m[0]);
40  
      Defer d = defers.get(id);
41  
      if (d != null)
42  
        return d.answer != null ? d.answer : "No answer yet.";
43  
      else
44  
        return "Defer ID " + id + " not found...";
45  
    }
46  
    
47  
    if (helper != null) {
48  
      new Defer defer;
49  
      helper.sendLine("Please advise, defer id: " + defer.id + ", command: " + quote(s));
50  
      return defer.toString();
51  
    }
52  
    
53  
    return null;
54  
  }
55  
  
56  
  static void state(S s) {
57  
    state = s;
58  
    print(s);
59  
  }
60  
  
61  
  static synchronized void runProgram(S programID) {
62  
    exception = null;
63  
    state("Loading "+ programID);
64  
    programClass = hotwire(programID);
65  
    state("Calling main");
66  
    try {
67  
      callMain(programClass);
68  
    } catch (Throwable e) {
69  
      exception = e;
70  
      state("main done with exception");
71  
    }
72  
    state("main done without exception");
73  
  }
74  
}

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: 582 / 636
Referenced in: [show references]