Project

General

Profile

Hinc » History » Version 2

Per Amundsen, 02/11/2014 08:03 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 2 Per Amundsen
-b - indicates &binvar is set.
10
-c - chop the &binvar to first null byte.
11 1 Per Amundsen
-m - creates the table if it does not exist.
12 2 Per Amundsen
-s - displays the result.
13 1 Per Amundsen
-uN - unsets the item after N seconds.
14 2 Per Amundsen
-z - decreases the item once per second until it reaches zero and then unsets it.
15 1 Per Amundsen
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>