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

1  
!7
2  
3  
cmodule GListMaker > DynObjectTable<S> {
4  
  bool active = true;
5  
  S globalID = aGlobalID();
6  
  
7  
  start {
8  
    onChange(r { saveStructFile(javaxDataDir("User Lists/" + aGlobalID() + ".txt"), clonedList()); });
9  
  }
10  
  
11  
  S answer(S s) {
12  
    if (!active) null;
13  
    if "list done|done" {
14  
      dm_call(dm_gazelle_modulesManager(), 'removeModule, this);
15  
      ret "Okidoki! Here's the final list with " + n_entries(count()) + ", saved as " + globalID + "):\n" + joinWithComma(list());
16  
    }
17  
    new Matches m;
18  
    if "add ..." {
19  
      if (contains($1)) ret $1 + " is already on the list!";
20  
      add($1);
21  
      ret $1 + " added to list. Now " + n_entries(count()) + ".";
22  
    }
23  
    if "remove ..." {
24  
      LS list = list();
25  
      int i = indexOfIC(list, $1);
26  
      if (i < 0) ret $1 + " is not on the list anyway.";
27  
      S item = list.get(i);
28  
      remove(item);
29  
      ret $1 + " removed from list!. Now " + n2(list(), "entry", "entries") + ".";
30  
    }
31  
    if "what's the list|list"
32  
      ret empty(list()) ? "Your list is empty." : joinWithComma(list());
33  
    null;
34  
  }
35  
36  
  // API
37  
38  
  bool contains(S s) { ret cic(list(), s); }
39  
}

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: 220 / 567
Version history: 18 change(s)
Referenced in: [show references]