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.

!747
!pcall

m {
  static S botID = "#1001756";
  static S botName = "Get Selected Table Line Helper Bot";
  static S cmd = "get selected table line as map";
  
  p {
    makeAndroid3("Get Selected Table Line Bot.");
  }
  
  static S answer(S s) {
    if (match3("get selected table line as map", s)) {
      new TreeMap<int, S> results;
      for (DialogIO vm : talkToAllOtherVMs()) {
        pcall {
          int vmPort = vm.getPort();
          Map<Number, S> bots = (Map) safeUnstructure(vm.ask("list bots"));
          print("VM " + vmPort + " bots: " + structure(bots));
          if (!containsBot(bots, botName)) {
            print("Injecting bot.");
            injectTo(vmPort, botID);
            
            int safetyCount = 0;
            while (!containsBot((Map) safeUnstructure(vm.ask("list bots")), botName)) {
              if (safetyCount >= 100) fail("bot did not start");
              sleep(500);
            }
          }
          S result = vm.ask("please forward to bot *: *", botName, cmd);
          results.put(vmPort, result);
        }
        vm.close();
      }
      
      // include myself
      Component focus = getFocusOwner();
      if (focus instanceof JTable)
        results.put(myVMPort(), structure(getSelectedLineAsMap((JTable) focus)));
        
      Map result = getResult(results);
      ret structure(result);
    }
    
    ret null;
  }
  
  static Map getResult(Map<int, S> results) {
    for (S s: results.values())
      if (structIsMap(s))
        ret (Map) unstructure(s);
    ret null;
  }
}

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: 580 / 618
Version history: 1 change(s)
Referenced in: [show references]