mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2017
Posts: 47
D
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Oct 2017
Posts: 47
Hi!

I cannot see any valid reason why /hdel -w stops the code if hash table doesn't exists, it should work the same way as /hfree -w works instead, just ignoring the command if the hash table doesn't exists would be a reason to use it for deleting item/items from the hash table directly without checking it first by using an if statement, also i don't think this change would break any backward compatibility on any code.

Currently:
Code
//hadd -m test one 1 | hadd test two 1 | hadd test three 1 | hfree -w test | hdel -w test one | echo Done
; This is going to stop the code on /hdel -w by giving an error because before the table does not exists.

//hadd -m test one 1 | hadd test two 1 | hadd test three 1 | hfree -w test | if ($hget(test)) hdel -w test one | echo Done
; In order to avoid that error you have to check for that table if exists before executing it to avoid any errors, now think about having several tables/items
; that you want to delete fast, you have to add a lot of if checks without a reason that you can avoid them if just /hdel -w won't stop the code with an error.


Suggestion:
Code
//hadd -m test one 1 | hadd test two 1 | hadd test three 1 | hfree -w test | hdel -w test one | echo Done
; This is going to proceed the code on /hdel -w by echoing "Done" even if the table does not exists.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This change would make sense. If this is determined to be in conflict with backwards compatibility, then a split the baby compromise would be to enable the -mN switch for /hdel, though this would have the side-effect of creating the table, though this would need an executive decision as to whether the table should be created for a no-match. My vote is no, but I flunked out of the Electoral College.

Either of these changes would simplify scripts by avoiding the need to check if the table has been created or not freed, before deleting a hashtable item which may/maynot exist.

hdel -swm1 table item


Link Copied to Clipboard