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

55
LINES

< > BotCompany Repo | #1001758 // Get Selected Table Line Bot (searches all VMs at every request!)

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

Transpiled version (2124L) is out of date.

1  
!747
2  
!pcall
3  
4  
m {
5  
  static S botID = "#1001756";
6  
  static S botName = "Get Selected Table Line Helper Bot";
7  
  static S cmd = "get selected table line as map";
8  
  
9  
  p {
10  
    makeAndroid3("Get Selected Table Line Bot.");
11  
  }
12  
  
13  
  static S answer(S s) {
14  
    if (match3("get selected table line as map", s)) {
15  
      new TreeMap<int, S> results;
16  
      for (DialogIO vm : talkToAllOtherVMs()) {
17  
        pcall {
18  
          int vmPort = vm.getPort();
19  
          Map<Number, S> bots = (Map) safeUnstructure(vm.ask("list bots"));
20  
          print("VM " + vmPort + " bots: " + structure(bots));
21  
          if (!containsBot(bots, botName)) {
22  
            print("Injecting bot.");
23  
            injectTo(vmPort, botID);
24  
            
25  
            int safetyCount = 0;
26  
            while (!containsBot((Map) safeUnstructure(vm.ask("list bots")), botName)) {
27  
              if (safetyCount >= 100) fail("bot did not start");
28  
              sleep(500);
29  
            }
30  
          }
31  
          S result = vm.ask("please forward to bot *: *", botName, cmd);
32  
          results.put(vmPort, result);
33  
        }
34  
        vm.close();
35  
      }
36  
      
37  
      // include myself
38  
      Component focus = getFocusOwner();
39  
      if (focus instanceof JTable)
40  
        results.put(myVMPort(), structure(getSelectedLineAsMap((JTable) focus)));
41  
        
42  
      Map result = getResult(results);
43  
      ret structure(result);
44  
    }
45  
    
46  
    ret null;
47  
  }
48  
  
49  
  static Map getResult(Map<int, S> results) {
50  
    for (S s: results.values())
51  
      if (structIsMap(s))
52  
        ret (Map) unstructure(s);
53  
    ret null;
54  
  }
55  
}

Author comment

Began life as a copy of #1001752

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1001758
Snippet name: Get Selected Table Line Bot (searches all VMs at every request!)
Eternal ID of this version: #1001758/2
Text MD5: 63e4ef48ff0a4cc0aaad6c738c801d73
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-11 22:55:49
Source code size: 1608 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 526 / 547
Version history: 1 change(s)
Referenced in: [show references]