Skip to content

Commit eceff7d

Browse files
A simple who command example.
1 parent 68bc8f5 commit eceff7d

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

Examples/Example 1.md

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Function Snippets
2+
## List Grab
3+
Contents to store
4+
```
5+
elements(%0,lmath(min,firstof(filterbool(#lambda/%%0,iter(%1,match(%0,%i0,%2),%2)),0)),%2)
6+
```
7+
8+
### Call
9+
> `u(listgrab, <list>, <patternlist>, [delimiter])`
10+
> => result
11+
12+
### Expected behavior
13+
Extension of grab() which returns the first word in <list> which matches any of the patterns in <patternlist> (%1).
14+
Both <list> and <patternlist> must use the same [delimiter], if specified (defaults to space.)
15+
16+
### Example usage:
17+
`think listgrab(foo bar baz qux,ba* qu*)`
18+
> bar
19+
20+
## All List Grab
21+
Contents to store
22+
```
23+
elements(%0,lmatch(%1,%2,strfirstof(%3,%b)),strfirstof(%3,%b),strfirstof(%4,%b))
24+
```
25+
26+
### Call
27+
> `u(agrab, <values>, <columninfo>, <columnnames>, <delim>, <osep>)`
28+
> columnvalues
29+
30+
### Documentation
31+
This function allows you to grab the values in a delimited <values> list, by giving the function a <columninfo> for its second attribute that contains the aliases or names of the locations of the values. The <columnnames> list then withdraws the values found at the locations in the <values> list, corresponding to the names found in <columninfo>. The <delim>item is the delimiter, and the <osep>is the outseperator.
32+
33+
### Notes
34+
lmatch is not a standard function. See the 'List Match' example for lmatch.
35+
36+
### Example usage
37+
`think u(agrab,-5 6 88 3,DEX AGI MAG FIRE,MAG DEX)`
38+
> 88 -5
39+
40+
## List Match
41+
Contents to store
42+
```
43+
iter(%1,match(%0,%i0,strfirstof(%2,%b)),strfirstof(%2,%b),strfirstof(%3,%b))
44+
```
45+
46+
### Call
47+
> `u(lmatch, <originlist>, <searchitemlist>, <delim>, <osep>)`
48+
> foundlist
49+
50+
### Documentation
51+
This function compares <searchitemlist> to <originlist>, and returns the locations of the found items from <searchitemlist> in <originlist> as FOUNDLIST. The <delim> and <osep> are delimiter and Out Seperator.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# A Simple Who command
2+
## Code
3+
```
4+
@create Generic Command Holder
5+
@set Generic Command Holder=!no_command
6+
&cmd`who Generic Command Holder=$+swho:@nspemit %:=u(fun`header,+swho)%r[u(fun`who)]%r[u(fun`footer)]
7+
&fun`header Generic Command Holder=center(\[%b%0%b\],width(%#),-)
8+
&fun`who Generic Command Holder=map(fun`who`line,lwho(),%b,%r)
9+
&fun`who`line Generic Command Holder=align(24 >20 >20,name(%0),timestring(idle(%0)),timestring(conn(%0)))
10+
&fun`footer Generic Command Holder=repeat(-,width(%#))
11+
```
12+
13+
## Invoking the command:
14+
`+swho`
15+
16+
## Expected Output
17+
```
18+
--------------------------------------------[ +swho ]--------------------------------------------
19+
Thylonicus 6m 37s 1h 0m 21s
20+
Shaenyl 18m 13s 1h 46m 37s
21+
Alastair 1h 43m 38s 11h 26m 39s
22+
Sumta 17m 37s 12h 32m 8s
23+
Mercutio 0s 2d 8h 19m 34s
24+
Balerion 6d 9h 2m 14s 6d 9h 2m 15s
25+
Nymeria 7d 6h 3m 2s 7d 6h 3m 2s
26+
qa'toq 2d 4h 9m 55s 7d 6h 6m 35s
27+
hellspawn 6m 25s 10d 3h 20m 5s
28+
Ambrosia 12d 7h 44m 37s 12d 7h 44m 37s
29+
Sigc 1d 12h 28m 22s 15d 11h 37m 14s
30+
Nhoj 87d 11h 58m 43s 87d 11h 58m 47s
31+
Rince 209d 10h 31m 27s 210d 20h 53m 26s
32+
eery 158d 8h 23m 43s 216d 8h 48m 43s
33+
Zebranky 142d 3h 29m 10s 324d 1h 1m 44s
34+
grapenut 15d 5h 8m 2s 360d 5h 3m 13s
35+
Glass 87d 9h 33m 31s 487d 9h 53m 27s
36+
Raevnos 8d 0h 8m 55s 1021d 23h 31m 42s
37+
-------------------------------------------------------------------------------------------------
38+
```

0 commit comments

Comments
 (0)