From WikiChip
Editing mirc/commands/hadd

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 10: Line 10:
 
* '''-z''' - Decreases the value by 1.0 every second; unsets at zero
 
* '''-z''' - Decreases the value by 1.0 every second; unsets at zero
 
* '''-uN''' - Removes the item/value after N seconds
 
* '''-uN''' - Removes the item/value after N seconds
* '''-k''' - Keeps the remaining time left from the -uN and -z switches (undocumented in help file)
+
* '''-k''' - Keeps the remaining time left from the -uN switch (undocumented in help file)
 
* '''-b''' - Treats the value as a binary variable
 
* '''-b''' - Treats the value as a binary variable
 
* '''-c''' - Truncates the &bvar at the first null value
 
* '''-c''' - Truncates the &bvar at the first null value
Line 39: Line 39:
 
* Creates item named "time" in hashtable "test". If table "test" did not already exist, that table is first created with 50 buckets. If it already existed, the number of buckets remains the same, and any other existing item/data are not affected.
 
* Creates item named "time" in hashtable "test". If table "test" did not already exist, that table is first created with 50 buckets. If it already existed, the number of buckets remains the same, and any other existing item/data are not affected.
  
//hadd -z test countdown 123.45 | .timerX 5 1 echo 4 -a value $!hget(test,countdown) unsets in $!hget(test,countdown).unset
+
/hadd -z test countdown 123.45
 
* Creates item named "countdown" with the value 123.45 then decrements it by 1 each second, preserving fractions, as long as the number remains positive. If decrementing results in the value being zero or negative, the item is unset. At creation, the item is given the unset value of 2^31-1 seconds in the future, regardless of the value. This item is not guaranteed to be unset 124 seconds from now, because /hinc or /hdec used with the -k switch can change the value while preserving the countdown behavior.
 
* Creates item named "countdown" with the value 123.45 then decrements it by 1 each second, preserving fractions, as long as the number remains positive. If decrementing results in the value being zero or negative, the item is unset. At creation, the item is given the unset value of 2^31-1 seconds in the future, regardless of the value. This item is not guaranteed to be unset 124 seconds from now, because /hinc or /hdec used with the -k switch can change the value while preserving the countdown behavior.
  
//hadd -zu3 test countdown 123.45 | .timerX 5 1 echo 4 -a value $!hget(test,countdown) unsets in $!hget(test,countdown).unset
+
/hadd -u30 Voting Open 1
* Same as above, except -u3 causes the item to unset 3 seconds in the future before it decements to zero.
+
* creates an item named "Open" in existing table "Voting" containing the value 1, which unsets 30 seconds in the future.
  
//hadd -mu30 Voting Open 30 | echo 4 -a val $hget(voting,open) unset delay $hget(voting,open).unset | hadd -z Voting Open 10 | .timerX 5 1 echo 3 -a val $!hget(voting,open) unset delay $!hget(voting,open).unset
+
/hadd -k Voting Open 11
* Creates table "Voting" if it doesn't already exist, with default buckets 100. Creates an item named "Open" containing the value 1, which unsets 30 seconds in the future. Then it updates the variable to value 10, and -z resets the unset delay from 30 seconds to be 2^31-1 seconds in the future.
+
If the item does not already exist, the -k switch has no effect. If the item already exists, and if it has a non-zero number of seconds to be unset in the future, the item's data value is updated to 11 without altering the unset countdown. If the item had been created using the -z switch, it retains the non-zero countdown for unset (in excess of 2 billion seconds) but loses the property of decrementing by 1 each second.
 
 
//hadd -mu30 Voting Open 30 | echo 4 -a val $hget(voting,open) unset delay $hget(voting,open).unset | hadd Voting Open 10 | .timerX 5 1 echo 3 -a val $!hget(voting,open) unset delay $!hget(voting,open).unset
 
* Same as above, except re-creating the variable without any switches resets the unset delay to 0, where it will not unset in the future.
 
 
 
//hadd -mu30 Voting Open 30 | hdel Voting Open | .timerX 5 1 hadd -ku99 Voting Open $!asctime $(|) echo 3 -a val $!hget(voting,open) unset delay $!hget(voting,open).unset
 
* -k is ignored the first time because the item does not exist, causing the item to be given a 99 seconds delay. But after that, the item having a non-zero unset delay means the -k switch causes the -u99 to be ignored, preserving the unset delay of an existing item. If the item had been created using the -z switch, it retains the non-zero unset delay (in excess of 2 billion seconds) but loses the property of decrementing by 1 each second if -z is not used again.
 
  
 
//hfree -w test | hadd -mz test item1 33  | hadd test item2 44 | hadd -u30 test item3 55 | hsave -u test deleteme.txt
 
//hfree -w test | hadd -mz test item1 33  | hadd test item2 44 | hadd -u30 test item3 55 | hsave -u test deleteme.txt
Line 61: Line 55:
  
 
//bset &var1 1 97 98 99 00 100 101 | hadd -smbc test bintest &var1 | noop $hget(test,bintest,&var2) | echo -a $bvar(&var2,0) $bvar(&var2,1-)
 
//bset &var1 1 97 98 99 00 100 101 | hadd -smbc test bintest &var1 | noop $hget(test,bintest,&var2) | echo -a $bvar(&var2,0) $bvar(&var2,1-)
* same except the contents of item 'bintest' is truncated, containing only the bytes prior to the first 0x00 byte if any.
+
* same except the contents of item 'bintest' is truncated, containing only the 3 bytes prior to the first 0x00 byte if any.
  
 
//hfree -w test | hadd -m test $ $+ version $+ $chr(32) $+ foo % $+ variable | echo 4 -a item= $hget(test,1).item data= $hget(test,1).data
 
//hfree -w test | hadd -m test $ $+ version $+ $chr(32) $+ foo % $+ variable | echo 4 -a item= $hget(test,1).item data= $hget(test,1).data

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)