Hinc » History » Version 1
Per Amundsen, 02/11/2014 07:59 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | */hinc [-bcmsuNz] <name> <item> [num | &binvar]* |
||
4 | |||
5 | Increases the value of the item by 'num'. |
||
6 | |||
7 | *Switches* |
||
8 | |||
9 | -s - displays the result. |
||
10 | -m - creates the table if it does not exist. |
||
11 | -b - indicates binvar is set. |
||
12 | -c - chop the binvar to first null byte. |
||
13 | -z - decreases the item once per second until it reaches zero and then unsets it. |
||
14 | -uN - unsets the item after N seconds. |
||
15 | |||
16 | *Parameters* |
||
17 | |||
18 | <name> - The hashtable where the <item> is stored. |
||
19 | <item> - The hashtable item to increase. |
||
20 | [num | &binvar] - The number or &binvar to increase by. |
||
21 | |||
22 | *Example* |
||
23 | |||
24 | <pre> |
||
25 | alias example { |
||
26 | ;Create a hashtable. |
||
27 | /hmake -s example |
||
28 | |||
29 | ;Add a few items. |
||
30 | /hadd example item1 4 |
||
31 | /hadd example item2 7 |
||
32 | /hadd example item3 9 |
||
33 | |||
34 | ;Print the items. |
||
35 | /echo -a item1 = $hget(example, item1) |
||
36 | /echo -a item2 = $hget(example, item2) |
||
37 | /echo -a item3 = $hget(example, item3) |
||
38 | |||
39 | ;Increase the values. |
||
40 | /hinc example item1 5 |
||
41 | /hinc example item2 12 |
||
42 | /hinc example item3 1 |
||
43 | |||
44 | /echo -e - |
||
45 | |||
46 | ;Print the items. |
||
47 | /echo -a item1 = $hget(example, item1) |
||
48 | /echo -a item2 = $hget(example, item2) |
||
49 | /echo -a item3 = $hget(example, item3) |
||
50 | |||
51 | ;Cleanup. |
||
52 | /hfree -s example |
||
53 | } |
||
54 | </pre> |