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

38
LINES

< > BotCompany Repo | #1020991 // Java Condition To Code [Input to Code]

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

Uses 911K of libraries. Click here for Pure Java version (19426L/110K).

!7

concept Entry {
  S condition, code;
  bool enabled = true;
  transient O runnable;
}

set flag DynModule.

compact module JavaInputConditionToCode > DynCRUD<Entry> {
  *() { super(Entry); }

  start {
    db();
    dm_onTopInput(voidfunc(fS s) {
      thread {
        for (Entry e : conceptsWhere(Entry, enabled := true))
 pcall {
          if (e.runnable == null)
            e.runnable = codeToFunctionOnString(e.condition);
          if (isTrue(callF(e.runnable, s))) {
            print("JCTC running " + e.id);
            S code = trim(e.code);
            bool say = startsWith(code, "=");
            if (say) code = substring(code, 1);
            try {
              temp tempSetTL(evalJava_prep_args, "fS s");
              O result = dm_evalJava_withModule(code, s);
              if (say) dm_say(strOrNull(result));
            } catch print _e {
              if (say) dm_say("Internal error, Sir");
            }
          }
        }
      }
    });
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020991
Snippet name: Java Condition To Code [Input to Code]
Eternal ID of this version: #1020991/5
Text MD5: 763f2bc0735c747317a7f17d6224e90c
Transpilation MD5: 20ad41f921caf1834a11f85dab99a979
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-16 01:13:08
Source code size: 1008 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 236 / 1233
Version history: 4 change(s)
Referenced in: [show references]