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

m (Bot: de-linking old mIRC menu)
Line 1: Line 1:
 
{{mirc title|/hdel Command}}
 
{{mirc title|/hdel Command}}
The '''/hdel command''' deletes a key/value pair from an existing hash table.
+
The '''/hdel''' command deletes an item/data-value pair from an existing hash table.
 
 
 
== Synopsis ==
 
== Synopsis ==
  /hdel [-sw] <nowiki><table></nowiki> <key>
+
  /hdel [-sw] <nowiki><table></nowiki> <item>
 
 
 
== Switches ==
 
== Switches ==
* '''-s''' - Displays the assignment information
+
* '''-s''' - Displays the Deletion action if the variable exists, displays error if table doesn't exist, no display if the table exists but the item does not.
 
* '''-w''' - Treats <nowiki><table></nowiki> as a wildcard and deletes all matching tables.
 
* '''-w''' - Treats <nowiki><table></nowiki> as a wildcard and deletes all matching tables.
 
 
== Parameters ==
 
== Parameters ==
 
* '''<nowiki><table></nowiki>''' - The table which contains the item you are deleting
 
* '''<nowiki><table></nowiki>''' - The table which contains the item you are deleting
* '''<key>''' - the key associated with a value to delete.
+
* '''<item>''' - the item-name associated with a value to delete. Can be a wildcard when using -w switch.
 
 
 
== Example ==
 
== Example ==
 
<syntaxhighlight lang="mIRC">alias hdel_example {
 
<syntaxhighlight lang="mIRC">alias hdel_example {
Line 38: Line 34:
 
}</syntaxhighlight>
 
}</syntaxhighlight>
  
 +
<source lang="mIRC">
 +
//hfree -sw test | hadd -m1 test item1 | hadd test item* | echo -a 1st item is $hget(test,1).item | hdel -w test item* | echo  -a there are $hget(test,0).item items remaining
 +
* Demonstrates that an item can be created and deleted containing an asterisk. If the -w switch is deleted, only 1 of the 2 items is deleted because of an exact item-name match with "item*".
 +
 +
//hfree -sw test | hmake -s test | hdel -s test itemname | echo -a message 1 | hfree -s test | hdel -s test itemname | echo -a message 2
 +
* Demonstrates that deleting a non-existent item from an existing table allows the script flow to continue, but deleting an item from a non-existent table is an error halting the script flow preventing the 2nd message from displaying.
 +
</source>
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|5.8}}
 
{{mIRC compatibility|5.8}}
 
 
== See also ==
 
== See also ==
* [[List of commands - mIRC|List of commands]]
+
{{collist
* [[List of identifiers - mIRC|List of identifiers]]
+
|count = 3
* {{mIRC|$hfind}}
+
|style = width: 60%; display: inherit;
* {{mIRC|$hget}}
+
|
* {{mIRC|/hadd}}
+
* {{mIRC|/hmake}}
* {{mIRC|/hdec}}
 
 
* {{mIRC|/hfree}}
 
* {{mIRC|/hfree}}
* {{mIRC|/hinc}}
 
 
* {{mIRC|/hload}}
 
* {{mIRC|/hload}}
* {{mIRC|/hmake}}
 
 
* {{mIRC|/hsave}}
 
* {{mIRC|/hsave}}
{{mIRC command list}}
+
* {{mIRC|/hadd}}
 
+
* {{mIRC|/hinc}}
[[Category:mIRC commands|hdel command - mIRC]]
+
* {{mIRC|/hdec}}
 +
* {{mIRC|Hash Tables}}
 +
* {{mIRC|$hget}}
 +
* {{mIRC|$hfind}}
 +
}}

Revision as of 15:12, 13 June 2018

The /hdel command deletes an item/data-value pair from an existing hash table.

Synopsis

/hdel [-sw] <table> <item>

Switches

  • -s - Displays the Deletion action if the variable exists, displays error if table doesn't exist, no display if the table exists but the item does not.
  • -w - Treats <table> as a wildcard and deletes all matching tables.

Parameters

  • <table> - The table which contains the item you are deleting
  • <item> - the item-name associated with a value to delete. Can be a wildcard when using -w switch.

Example

alias hdel_example {
  ;add items
  hadd -m example academic a
  hadd example academy a
  hadd example accelerate a
  hadd example accelerator a
  hadd example accept a
  hadd example access a
  hadd example accident a
  hadd example because b
 
  ;number of items
  echo -a $hget(example, 0).item
 
  ;remove everything by one
  hdel -w example a*
 
  ;number of items
  echo -a $hget(example, 0).item
 
  ;free table
  hfree example
}
//hfree -sw test | hadd -m1 test item1 | hadd test item* | echo -a 1st item is $hget(test,1).item | hdel -w test item* | echo  -a there are $hget(test,0).item items remaining
* Demonstrates that an item can be created and deleted containing an asterisk. If the -w switch is deleted, only 1 of the 2 items is deleted because of an exact item-name match with "item*".
 
//hfree -sw test | hmake -s test | hdel -s test itemname | echo -a message 1 | hfree -s test | hdel -s test itemname | echo -a message 2
* Demonstrates that deleting a non-existent item from an existing table allows the script flow to continue, but deleting an item from a non-existent table is an error halting the script flow preventing the 2nd message from displaying.

Compatibility

Added: mIRC v5.8
Added on: 05 Sep 2000
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also