mIRC Homepage
Posted By: Buggs2008 Re-Write an entry in a hash table - 07/11/08 03:04 AM
Hello,

I couldn't find any reference material on the net,

on how to re-write or change an item / data in a hash table.

Can this be done? If so how?

Thanks in advance

Cheers,

Jay.
The same way you wrote to it in the first place:
/hadd <table> <item> <data>
Posted By: Tomao Re: Re-Write an entry in a hash table - 07/11/08 04:15 AM
Or I suppose you can use /hdel to get rid of the previous entry and then overwrite with a new set of item and data:

Code:
alias rewrite {
  if (!$hget(Test)) hadd -m Test 1 2
  hdel -sw Test 1 2
  hadd Test 3 4
  hdel -sw Test 3 4
  hadd Test 5 6
}
Posted By: RusselB Re: Re-Write an entry in a hash table - 07/11/08 04:27 AM
You could, but why you would want to when using the /hadd command over-writes the previous entry, I have no idea.

Also noticed the following:
1) The s switch displays the results in the status window
2) The w switch makes the /hdel work with wildcards, which are non-existant in your code.
3) Only the table name and item are required for /hdel (eg:
Code:
/hdel Test 1
works perfectly fine)
Posted By: Tomao Re: Re-Write an entry in a hash table - 07/11/08 04:55 AM
Quote:
1) The s switch displays the results in the status window


I beg to differ, RusselB. The -s switch makes the hash tables display the result according to the help file.

But you may be right, because it does show in the active window instead of the status, though.
Posted By: RusselB Re: Re-Write an entry in a hash table - 07/11/08 05:52 AM
You may be correct, I usually have the status window as the active window when testing things like that, so the s switch would've showed in the status window in my case.

Still seems foolish to have the result displayed when using the /hdel command, as you are deleting the entry, therefore the displayed result would be unnoticeable (ie: $null)
Posted By: DJ_Sol Re: Re-Write an entry in a hash table - 07/11/08 08:21 AM
I believe '-s' in this sense means 'show' and not status.

As far as I know Khaled only explained this switch in the variables section of the help file.


Quote:
Note: You can use /var -s to make a variable show the result when a value is set, and /var -g to set a global variable.

Posted By: Buggs2008 Re: Re-Write an entry in a hash table - 07/11/08 04:06 PM
Thank you so much everyone for helping me.

I didnt realiase it was that easy to overwrite an existing entry in a hash table.

Cheers,

Jay.
Posted By: Buggs2008 Re: Re-Write an entry in a hash table - 07/11/08 04:06 PM
Thank you so much everyone for helping me.

I didnt realiase it was that easy to overwrite an existing entry in a hash table.

Cheers,

Jay.
Posted By: Tomao Re: Re-Write an entry in a hash table - 07/11/08 06:47 PM
Quote:
as you are deleting the entry, therefore the displayed result would be unnoticeable (ie: $null)


First of all, thanks DJ_Sol for the clarification of the -s switch in the hash tables.

To RusselB, it shows the result of a deleted item in the hash tables. So it's not a $null.

/hdel -s Test 1

*Deleted item '1' from hash table 'Test'
Posted By: DJ_Sol Re: Re-Write an entry in a hash table - 07/11/08 07:40 PM
Tamao, reread what russelb said.

Your example showed:

/hdel table item data


When all you need for /hdel is the table and item.

Thank you for participating!
Posted By: Tomao Re: Re-Write an entry in a hash table - 07/11/08 09:31 PM
Excuse me for misreading Russel's post, and thanks for the lesson learned.
Posted By: Pivo Re: Re-Write an entry in a hash table - 08/11/08 09:56 PM
Originally Posted By: DJ_Sol
As far as I know Khaled only explained this switch in the variables section of the help file.


What about...

Quote:
The -s switch makes the command display the result.

/help /hmake
© mIRC Discussion Forums