static synchronized S manageStringList(S s, S name, S varName, boolean canChange) { L<S> list = (L) get(main.class, varName); new Matches m; if (match("list " + plural(name), s)) ret structure(list); if (match("how many " + plural(name), s)) ret str(l(list)); if (match("add " + name + " *", s, m)) { if (!canChange) ret "Sorry. Not authorized"; S id = m.unq(0); list.add(id); save(varName); ret "OK, " + name + " " + quote(id) + " added. List size now: " + l(list); } if (match("remove " + name + " *", s, m)) { if (!canChange) ret "Sorry. Not authorized"; S id = m.unq(0); int idx = list.indexOf(id); if (idx < 0) ret id + " is not a " + name; list.remove(idx); save(varName); ret "OK, " + name + " " + quote(id) + " removed. List size now: " + l(list); } ret null; }
Began life as a copy of #1002457
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: | #1002628 |
Snippet name: | manageStringList - convenient way of managing a list of unchecked strings |
Eternal ID of this version: | #1002628/1 |
Text MD5: | d0697e97e8d5fa512d261e8eba553eea |
Author: | stefan |
Category: | eleu |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-06 03:20:32 |
Source code size: | 893 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 705 / 632 |
Referenced in: | [show references] |