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

29
LINES

< > BotCompany Repo | #1006502 // tok_repeatWithSleep

JavaX fragment (include)

1  
static bool tok_repeatWithSleep_verbose;
2  
3  
static L<S> tok_repeatWithSleep(L<S> tok) {
4  
  int i;
5  
  while ((i = jfind(tok, "repeat with sleep * {")) >= 0) {
6  
    S seconds = tok.get(i+6); // int or id
7  
    int idx = findCodeTokens(tok, i, false, "{");
8  
    int j = findEndOfBracketPart(tok, idx);
9  
    if (tok_repeatWithSleep_verbose) print("idx=" + idx + ", j=" + j);
10  
    clearTokens(tok, i, idx+1);
11  
    tok.set(i, "repeat { pcall {");
12  
    tok.set(j-1, "} sleepSeconds(" + seconds + "); }");
13  
    reTok(tok, j-1, j);
14  
    reTok(tok, i, idx+1);
15  
  }
16  
  
17  
  while ((i = jfind(tok, "repeat with ms sleep * {")) >= 0) {
18  
    S ms = tok.get(i+8); // int or id
19  
    int idx = findCodeTokens(tok, i, false, "{");
20  
    int j = findEndOfBracketPart(tok, idx);
21  
    if (tok_repeatWithSleep_verbose) print("idx=" + idx + ", j=" + j);
22  
    clearTokens(tok, i, idx+1);
23  
    tok.set(i, "repeat { pcall {");
24  
    tok.set(j-1, "} sleep(" + ms + "); }");
25  
    reTok(tok, j-1, j);
26  
    reTok(tok, i, idx+1);
27  
  }
28  
  ret tok;
29  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006502
Snippet name: tok_repeatWithSleep
Eternal ID of this version: #1006502/2
Text MD5: 641a78a1a806efffb526da2b223a4f01
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-03 05:25:06
Source code size: 1016 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 529 / 589
Version history: 1 change(s)
Referenced in: [show references]