Project

General

Profile

Hdec » History » Version 2

Per Amundsen, 02/11/2014 03:47 PM

1 1 Per Amundsen
_Added in 1.9.0_
2
3
*/hdec -bcmsuNz <name> <item> [num | &binvar]*
4
5
Decreases the value of the item by 'num'.
6
7
*Switches*
8
9
-b - Indicates &binvar is set.
10
-c - Chop the &binvar to first null byte.
11
-m - Creates the table if it does not exist.
12
-s - Displays the result.
13
-uN - Unset the the item after N seconds.
14
-z - Decreases the item once per second until it reaches zero and then unsets it.
15
16
*Parameters*
17
18
<name> - The hashtable where the item resides.
19
<item> - The hashtable item to decrease.
20
[num | &binvar] - The number or &binvar to decrease by.
21
22
*Example*
23
24 2 Per Amundsen
<pre>
25 1 Per Amundsen
alias countdown {
26
  ;Adds the item down with a value of 10 to the table count.
27
  hadd -m count down 10
28
29
  echo -a $hget(count,down) $+ !
30
  :repeat
31
32
  ;Checks if the value of down returns true.
33
  if ($hget(count,down) > 1) {
34
    ;decreases down by 1
35
    hdec count down
36
    ;echos the current count
37
    echo -a $hget(count,down) $+ !
38
    ;repeats
39
    goto repeat
40
  }
41
  ;If the previous if statement returns false it carries on with this.
42
  else echo -a 0, Hurray!
43
  hfree -s count
44
}
45 2 Per Amundsen
</pre>