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

1  
!7
2  
3  
set flag DynModule.
4  
5  
srecord ScriptItem(S desc, S code) {
6  
  Double seconds;
7  
  S status;
8  
  
9  
  *(S *desc, S *code, double *seconds) {}
10  
}
11  
12  
sclass Scripter extends DynObjectTable<ScriptItem> {
13  
  int iRunning;
14  
  S status;
15  
  
16  
  start {
17  
    javaEval_useDiskCache();
18  
    
19  
    setData(ll(
20  
      ScriptItem("Say 1", [[infoBox("1")]], 4.0),
21  
      ScriptItem("Say 2", [[infoBox("2")]], 4.0)
22  
    ));
23  
  }
24  
  
25  
  visualize {
26  
    ret northAndCenter(
27  
      withMargin(centerAndEastWithMargin(rightAlignLabel(dm_fieldLabel('status)), jbutton("Run", r runIt))),
28  
      jSection("SCRIPT", super.visualize()));
29  
  }
30  
  
31  
  void runIt {
32  
    thread "Run Script" {
33  
      setFields(iRunning := 0, status := "running");
34  
      afterwards { setField(status := "done"); }
35  
      while (iRunning < l(data)) {
36  
        ScriptItem item = get(data, iRunning);
37  
        long targetTime = sysNow()+toMS(toDouble(item.seconds));
38  
        item.status = "running";
39  
        updateTable();
40  
        setField(iRunning := iRunning+1);
41  
        evalJava(item.code);
42  
        sleepUntilSys(targetTime);
43  
        item.status = "done";
44  
        updateTable();
45  
      }
46  
    }
47  
  }
48  
}

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: 382 / 771
Version history: 16 change(s)
Referenced in: [show references]