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

38
LINES

< > BotCompany Repo | #1000797 // "set" - Run program with changed variables [old]

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

Libraryless. Click here for Pure Java version (893L/6K/20K).

1  
// Syntax example: javax 1000797 timeout=500 1000796
2  
3  
!747
4  
!class _javax 19
5  
6  
m {
7  
  p {
8  
    int i;
9  
    for (i = 0; i < args.length; i++) {
10  
      int idx = args[i].indexOf("=");
11  
      if (idx < 0) break;
12  
    }
13  
    
14  
    S progID = args[i];
15  
    Class prog = hotwire(progID);
16  
    for (int j = 0; j < i; j++) {
17  
      S arg = args[j];
18  
      int idx = arg.indexOf("=");
19  
      S var = arg.substring(0, idx);
20  
      S value = arg.substring(idx+1);
21  
      setFlex(prog, var, value);
22  
    }
23  
    callMain(prog, dropFirst(i+1, args));
24  
  }
25  
  
26  
  static void setFlex(Class c, String var, String value) {
27  
    Field f = findField(c, var);
28  
    Class t = f.getType();
29  
    O v = value;
30  
    if (t == Integer.class || t == int.class)
31  
      v = Integer.parseInt(value);
32  
    else if (t == Long.class || t == long.class)
33  
      v = Long.parseLong(value);
34  
    else if (t == Boolean.class || t == boolean.class)
35  
      v = Boolean.parseBoolean(value);
36  
    set(c, var, v);
37  
  }
38  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000797
Snippet name: "set" - Run program with changed variables [old]
Eternal ID of this version: #1000797/1
Text MD5: ce4a96db9503d7bfc6c7d12459416bf0
Transpilation MD5: b777fc477fd6683dc4bf975a4e97d843
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-13 14:05:34
Source code size: 980 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 701 / 1143
Referenced in: [show references]