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

48
LINES

< > BotCompany Repo | #1018469 // Scripter [Dyn Module, Demo]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (17347L/125K).

!7

set flag DynModule.

srecord ScriptItem(S desc, S code) {
  Double seconds;
  S status;
  
  *(S *desc, S *code, double *seconds) {}
}

sclass Scripter extends DynObjectTable<ScriptItem> {
  int iRunning;
  S status;
  
  start {
    javaEval_useDiskCache();
    
    setData(ll(
      ScriptItem("Say 1", [[infoBox("1")]], 4.0),
      ScriptItem("Say 2", [[infoBox("2")]], 4.0)
    ));
  }
  
  visualize {
    ret northAndCenter(
      withMargin(centerAndEastWithMargin(rightAlignLabel(dm_fieldLabel('status)), jbutton("Run", r runIt))),
      jSection("SCRIPT", super.visualize()));
  }
  
  void runIt {
    thread "Run Script" {
      setFields(iRunning := 0, status := "running");
      afterwards { setField(status := "done"); }
      while (iRunning < l(data)) {
        ScriptItem item = get(data, iRunning);
        long targetTime = sysNow()+toMS(toDouble(item.seconds));
        item.status = "running";
        updateTable();
        setField(iRunning := iRunning+1);
        evalJava(item.code);
        sleepUntilSys(targetTime);
        item.status = "done";
        updateTable();
      }
    }
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018469
Snippet name: Scripter [Dyn Module, Demo]
Eternal ID of this version: #1018469/17
Text MD5: ed4173efe697994b10d9c95bbea37e80
Transpilation MD5: 237f6c9b697d9b20d2f54958fa33c54a
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-06 02:27:08
Source code size: 1169 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 313 / 692
Version history: 16 change(s)
Referenced in: [show references]