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

m (Bot: Automated text replacement (-<small>Note: Individual switches were not taken into consideration.</small> +))
(See also)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
The '''/hdel command''' deletes a key/value pair from an existing hash table.
+
{{mirc title|/hdel Command}}
 
+
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 {{mirc|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 {{mirc|wildcard}} when using -w switch.
 
 
 
== Example ==
 
== Example ==
 
<syntaxhighlight lang="mIRC">alias hdel_example {
 
<syntaxhighlight lang="mIRC">alias hdel_example {
Line 37: 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 ==
Added: mIRC v5.8
+
{{mIRC compatibility|5.8}}
 
 
Added On: 05/09/2000
 
 
 
 
 
 
 
 
== See also ==
 
== See also ==
* [[List of commands - mIRC|List of commands]]
+
* {{mIRC|/hmake}}
* [[List of identifiers - mIRC|List of identifiers]]
 
* {{mIRC|$hfind}}
 
* {{mIRC|$hget}}
 
* {{mIRC|/hadd}}
 
* {{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]]
+
* {{mIRC|/hdec}}
 +
* {{mIRC|Hash Tables}}
 +
* {{mIRC|$hget}}
 +
* {{mIRC|$hfind}}

Latest revision as of 18:28, 2 May 2023

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

Synopsis[edit]

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

Switches[edit]

  • -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[edit]

  • <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[edit]

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[edit]

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[edit]