From WikiChip
Difference between revisions of "mirc/commands/hdec"
< mirc‎ | commands

m (Bot: Automated text replacement (-<small>Note: Individual switches were not taken into consideration.</small> +))
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The '''/hdec command''' decreases the value of a key by [num]. If the value is not specified, the default value is 1.0.
+
{{mirc title|/hdec Command}}
 
+
The '''/hdec''' command decreases the value of a hashtable item by [num]. If the optional number value is not specified, the default increment value is 1. It uses the same syntax as /hadd except -b's &binvar is the [num] parameter not the destination.
 
== Synopsis ==
 
== Synopsis ==
  /hdec [-mszu#] <table> <key> [num]  
+
  /hdec [-m[N]szuN] <nowiki>‹table›</nowiki> <item> [num]
  /hdec -b[cmszu#] <table> <key> <&bvar>
+
  /hdec -b[m[N]szuN] <nowiki>‹table></nowiki> <item> <&bvar>
 
 
 
== Switches ==
 
== Switches ==
* '''-m''' - Creates the hash table if it does not exist  
+
* '''-m[N]''' - Creates the hash table if it does not exist, optionally setting the number of buckets to N. (Valid N 1-10000)
 
* '''-s''' - Displays the assignment information  
 
* '''-s''' - Displays the assignment information  
* '''-b''' - Treats the value as a binary variable
+
* '''-b''' - uses the .text contents of a &binvar as the [num] parameter.
* '''-c''' - Truncates the &bvar at the first null value
+
* '''-z''' - After setting the data's value, decreases the value by 1 each second; unsets to prevent the data value being zero or negative
* '''-z''' - Decreases the value by 1.0 every second; stops at zero  
+
* '''-uN''' - Removes the hashtable item/value after N seconds
* '''-u#''' - Removes the key/value after # seconds
+
'''Note:''' If hashtable item has a non-zero $hget(table,item).unset property due to using -uN or -z switches when created or modified by /hinc /hdec or /hadd, then /hsave will not save that item to disk without the /hsave -u switch. /hdec preserves any existing unset delay when -z and -uN switches are not used.
 
 
 
== Parameters ==
 
== Parameters ==
* '''<table>''' - The handle name of the table to operate on
+
* '''<nowiki><table></nowiki>''' - The handle name of the table containing the 'item'
* '''<key>''' - The key associated with the value  
+
* '''<item>''' - The item name associated with the data value
* '''[num]''' - The value to decrease the value by
+
* '''[num]''' - The optional value by which to decrease the data value. If not present, decreases by 1.0
* '''<&bvar>''' - The binary variable value to decrease the value by
+
* '''<&bvar>''' - The binary variable containing the value by which to decrease the 'item'
 +
== Example ==
 +
'''Note:''' For more examples see the {{mIRC|/hinc}} page. /hdec is the same as /hinc except for decrementing by [num] instead of incrementing.
  
== Example ==
 
 
<syntaxhighlight lang="mIRC">alias countdown {
 
<syntaxhighlight lang="mIRC">alias countdown {
 
   ;adds the item down with a value of 10 to the table count
 
   ;adds the item down with a value of 10 to the table count
Line 40: Line 39:
  
 
== Compatibility ==
 
== Compatibility ==
Added: mIRC v6.0
+
{{mIRC compatibility|6.0}}
 
 
Added On: 03/02/2002
 
 
 
 
 
 
 
 
 
 
== See also ==
 
== See also ==
* [[List of commands - mIRC|List of commands]]
+
* {{mIRC|/hmake}}
* [[List of identifiers - mIRC|List of identifiers]]
+
* {{mIRC|/hfree}}
* {{mIRC|$hget}}
+
* {{mIRC|/hload}}
* {{mIRC|$hfind}}
+
* {{mIRC|/hsave}}
 
* {{mIRC|/hadd}}
 
* {{mIRC|/hadd}}
 
* {{mIRC|/hdel}}
 
* {{mIRC|/hdel}}
* {{mIRC|/hfree}}
 
 
* {{mIRC|/hinc}}
 
* {{mIRC|/hinc}}
* {{mIRC|/hload}}
+
* {{mIRC|Hash Tables}}
* {{mIRC|/hmake}}
+
* {{mIRC|$hget}}
* {{mIRC|/hsave}}
+
* {{mIRC|$hfind}}
{{mIRC command list}}
 
 
 
[[Category:MIRC commands]]
 

Latest revision as of 18:28, 2 May 2023

The /hdec command decreases the value of a hashtable item by [num]. If the optional number value is not specified, the default increment value is 1. It uses the same syntax as /hadd except -b's &binvar is the [num] parameter not the destination.

Synopsis[edit]

/hdec [-m[N]szuN] ‹table› <item> [num]
/hdec -b[m[N]szuN] ‹table> <item> <&bvar>

Switches[edit]

  • -m[N] - Creates the hash table if it does not exist, optionally setting the number of buckets to N. (Valid N 1-10000)
  • -s - Displays the assignment information
  • -b - uses the .text contents of a &binvar as the [num] parameter.
  • -z - After setting the data's value, decreases the value by 1 each second; unsets to prevent the data value being zero or negative
  • -uN - Removes the hashtable item/value after N seconds

Note: If hashtable item has a non-zero $hget(table,item).unset property due to using -uN or -z switches when created or modified by /hinc /hdec or /hadd, then /hsave will not save that item to disk without the /hsave -u switch. /hdec preserves any existing unset delay when -z and -uN switches are not used.

Parameters[edit]

  • <table> - The handle name of the table containing the 'item'
  • <item> - The item name associated with the data value
  • [num] - The optional value by which to decrease the data value. If not present, decreases by 1.0
  • <&bvar> - The binary variable containing the value by which to decrease the 'item'

Example[edit]

Note: For more examples see the /hinc page. /hdec is the same as /hinc except for decrementing by [num] instead of incrementing.

alias countdown {
  ;adds the item down with a value of 10 to the table count
  hadd -m count down 10
  echo -a $hget(count,down) $+ !
  :repeat
  ;checks if the value of down returns true
  if ($hget(count,down) > 1) {
    ;decreases down by 1
    hdec count down
    ;echos the current count
    echo -a $hget(count,down) $+ !
    ;repeats
    goto repeat
  }
  ;if the previous if statement returns false it carries on with this.
  else echo -a 0, Hurray!
  hfree -s count
}

Compatibility[edit]

Added: mIRC v6.0
Added on: 03 Feb 2002
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also[edit]