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

39
LINES

< > BotCompany Repo | #1021930 // Gazelle List Maker

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

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

!7

cmodule GListMaker > DynObjectTable<S> {
  bool active = true;
  S globalID = aGlobalID();
  
  start {
    onChange(r { saveStructFile(javaxDataDir("User Lists/" + aGlobalID() + ".txt"), clonedList()); });
  }
  
  S answer(S s) {
    if (!active) null;
    if "list done|done" {
      dm_call(dm_gazelle_modulesManager(), 'removeModule, this);
      ret "Okidoki! Here's the final list with " + n_entries(count()) + ", saved as " + globalID + "):\n" + joinWithComma(list());
    }
    new Matches m;
    if "add ..." {
      if (contains($1)) ret $1 + " is already on the list!";
      add($1);
      ret $1 + " added to list. Now " + n_entries(count()) + ".";
    }
    if "remove ..." {
      LS list = list();
      int i = indexOfIC(list, $1);
      if (i < 0) ret $1 + " is not on the list anyway.";
      S item = list.get(i);
      remove(item);
      ret $1 + " removed from list!. Now " + n2(list(), "entry", "entries") + ".";
    }
    if "what's the list|list"
      ret empty(list()) ? "Your list is empty." : joinWithComma(list());
    null;
  }

  // API

  bool contains(S s) { ret cic(list(), s); }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021930
Snippet name: Gazelle List Maker
Eternal ID of this version: #1021930/19
Text MD5: ec7d25038ac92e6454385c3b58fa650c
Transpilation MD5: 1b91cdc26058a13c1aaf4c25da9bf21e
Author: stefan
Category: javax / gazelle
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-06 16:56:51
Source code size: 1160 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 216 / 561
Version history: 18 change(s)
Referenced in: [show references]