mIRC Home    About    Download    Register    News    Help

Print Thread
Re-Write an entry in a hash table #206076 07/11/08 03:04 AM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
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.

Re: Re-Write an entry in a hash table [Re: Buggs2008] #206077 07/11/08 03:13 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The same way you wrote to it in the first place:
/hadd <table> <item> <data>


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: Re-Write an entry in a hash table [Re: Buggs2008] #206078 07/11/08 04:15 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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
}

Re: Re-Write an entry in a hash table [Re: Tomao] #206080 07/11/08 04:27 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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)

Re: Re-Write an entry in a hash table [Re: RusselB] #206081 07/11/08 04:55 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Last edited by Tomao; 07/11/08 05:04 AM.
Re: Re-Write an entry in a hash table [Re: Tomao] #206083 07/11/08 05:52 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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)

Re: Re-Write an entry in a hash table [Re: Tomao] #206085 07/11/08 08:21 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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.


Re: Re-Write an entry in a hash table [Re: Buggs2008] #206096 07/11/08 04:06 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
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.

Re: Re-Write an entry in a hash table [Re: Buggs2008] #206097 07/11/08 04:06 PM
Joined: Oct 2007
Posts: 214
B
Buggs2008 Offline OP
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
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.

Re: Re-Write an entry in a hash table [Re: RusselB] #206101 07/11/08 06:47 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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'

Re: Re-Write an entry in a hash table [Re: Tomao] #206103 07/11/08 07:40 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
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!

Re: Re-Write an entry in a hash table [Re: DJ_Sol] #206107 07/11/08 09:31 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Excuse me for misreading Russel's post, and thanks for the lesson learned.

Re: Re-Write an entry in a hash table [Re: DJ_Sol] #206169 08/11/08 09:56 PM
Joined: Jun 2008
Posts: 58
P
Pivo Offline
Babel fish
Offline
Babel fish
P
Joined: Jun 2008
Posts: 58
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