From WikiChip
Editing mirc/commands/hinc

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|/hinc Command}}
+
The '''/hinc command''' increases the value of a key by [num]. If the value is not specified, the default value is 1.0.
The '''/hinc''' command increases 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 ==
  /hinc [-m[N]szuN] <nowiki><table></nowiki> <item> [num]
+
  /hinc [-mszu#] <nowiki><table></nowiki> <key> [num]  
  /hinc -b[m[N]szuN] <nowiki><table></nowiki> <item> <&bvar>
+
  /hinc -b[cmszu#] <nowiki><table></nowiki> <key> <&bvar>
  
 
== Switches ==
 
== Switches ==
* '''-m[N]''' - Creates the hash table if it does not exist, optionally setting the number of buckets to N. (Valid N 1-10000)
+
* '''-m''' - Creates the hash table if it does not exist  
* '''-s''' - Displays the assignment information
+
* '''-s''' - Displays the assignment information  
* '''-b''' - uses the .text contents of a &binvar as the [num] parameter.
+
* '''-b''' - Treats the value as a binary variable
* '''-z''' - After setting the data's value, decreases the value by 1 each second; unsets to prevent the data value being zero or negative
+
* '''-c''' - Truncates the &bvar at the first null value
* '''-uN''' - Removes the hashtable item/value after N seconds
+
* '''-z''' - Decreases the value by 1.0 every second; stops at zero  
'''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. /hinc preserves any existing unset delay when -z and -uN switches are not used.
+
* '''-u#''' - Removes the key/value after # seconds
 +
 
 
== Parameters ==
 
== Parameters ==
* '''<nowiki><table></nowiki>''' - The handle name of the table containing the 'item'
+
* '''<nowiki><table></nowiki>''' - The handle name of the table to operate on
* '''<item>''' - The item name associated with the data value
+
* '''<key>''' - The key associated with the value  
* '''[num]''' - The optional value by which to increase the data value. If not present, increases by 1.0
+
* '''[num]''' - The value to decrease the value by
* '''<&bvar>''' - The binary variable containing the value by which to decrease the 'item'
+
* '''<&bvar>''' - The binary variable value to decrease the value by
 +
 
 
== Example ==
 
== Example ==
 
Example 1:
 
Example 1:
Line 70: Line 72:
 
}</syntaxhighlight>
 
}</syntaxhighlight>
  
<source lang="mIRC">
+
== Compatibility ==
//hfree -sw test | hinc -sm test foo 5 | echo -a item foo has value $hget(test,foo)
+
Added: mIRC v6.0
Result: 5
 
* If the item does not exist, /hinc behaves as if the item exists with a value of zero.
 
  
//hfree -sw test | var %a 0 | hadd -sm test foo 5 | hinc test foo %a      | echo -a item foo has value $hget(test,foo)
+
Added On: 03/02/2002
Result: 5
 
//hfree -sw test | var %a  | hadd -sm test foo 5 | hinc test foo %a      | echo -a item foo has value $hget(test,foo)
 
Result: 6
 
//hfree -sw test | var %a  | hadd -sm test foo 5 | hinc test foo $+(0,%a) | echo -a item foo has value $hget(test,foo)
 
Result: 5
 
* If variable used to increment the item is $null the increment is the default 1 not zero.
 
  
//hfree -sw test | hadd -sm50 test foo 9.123456789 | echo -a item foo has value $hget(test,foo) | hinc -s test foo 2 | echo -a item foo has value $hget(test,foo)
 
* While a hash table value can be created having more than 6 decimals, the result of /hinc is rounded to nearest 6 decimals, the same result as if $calc(old_value + increment_value). If the [num] parameter is incorrectly set to be non-numeric, the item is unset 1 second later because $calc(string - 1) is zero.
 
  
//hfree -sw test | hadd -sm50 test foo 30 | echo -a item foo has value $hget(test,foo) | .timer 5 1 hinc -z test foo 50 $(|) echo 4 -a item foo has value $!hget(test,foo) and will unset in $!hget(test,foo).unset secs
 
* After the old value has been incremented (handles existing $null value as if zero), -z begins with the new incremented value then decreases it once per second, but also gives the item the characteristic as if -u2147483647 were also used. (2^31-1)
 
  
//hfree -sw test | hadd -sm50 test foo 30 | echo -a item foo has value $hget(test,foo) | .timer 5 1 hinc -zu30 test foo 50 $(|) echo 4 -a item foo has value $!hget(test,foo) and will unset in $!hget(test,foo).unset secs
 
* Same as above, except -u30 modifies the future unset time to be 30 seconds instead of 2147483647.
 
 
* Note: Any data value created or modified using the -z or -uN switch has the characteristic of being unset in the future, and /hsave will not save that item/data pair to disk unless the /hsave -u switch is used.
 
 
//hfree -sw test | hinc -smzu10 test foo 30.4 | .timer 11 1 echo 4 -a value $!hget(test,foo) vs .unset $!hget(test,foo).unset
 
//hfree -sw test | hinc -smzu10 test foo 5.44 | .timer 11 1 echo 4 -a value $!hget(test,foo) vs .unset $!hget(test,foo).unset
 
* When item is created using both -z and -uN, the variable is unset to prevent the first of either .unset seconds reaching zero or the value decrements to be zero or negative.
 
 
//hadd -m table item 123 | bset &v1 1 51 51 13 51  | echo -a inc $hget(table,item) by $bvar(&v1,1-).text | hinc table item $bvar(&v1,1-).text | echo 3 -a equals $hget(table,item)
 
//hadd -m table item 123 | bset &v1 1 51 51 13 51  | echo -a inc $hget(table,item) by $bvar(&v1,1-).text | hinc -b table item &v1 | echo 3 -a equals $hget(table,item)
 
* Using -b with &binvar as the NUM parameter is the same as using $bvar(&binvar).text as the NUM parameter without using -b
 
* The 3rd 3 is ignored because /hinc strips non-numeric string from the ending, increasing the item value 123 by 33.
 
</source>
 
== Compatibility ==
 
{{mIRC compatibility|6.0}}
 
 
== See also ==
 
== See also ==
* {{mIRC|/hmake}}
+
* [[List of commands - mIRC|List of commands]]
 +
* [[List of identifiers - mIRC|List of identifiers]]
 +
* {{mIRC|$hget}}
 +
* {{mIRC|$hfind}}
 +
* {{mIRC|/hadd}}
 +
* {{mIRC|/hdec}}
 +
* {{mIRC|/hdel}}
 
* {{mIRC|/hfree}}
 
* {{mIRC|/hfree}}
 
* {{mIRC|/hload}}
 
* {{mIRC|/hload}}
 +
* {{mIRC|/hmake}}
 
* {{mIRC|/hsave}}
 
* {{mIRC|/hsave}}
* {{mIRC|/hadd}}
+
{{mIRC command list}}
* {{mIRC|/hdel}}
+
 
* {{mIRC|/hdec}}
+
[[Category:MIRC commands]]
* {{mIRC|Hash Tables}}
 
* {{mIRC|$hget}}
 
* {{mIRC|$hfind}}
 

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)