mIRC Home    About    Download    Register    News    Help

Topic Options
#206076 - 07/11/08 03:04 AM Re-Write an entry in a hash table
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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.

Top
#206077 - 07/11/08 03:13 AM Re: Re-Write an entry in a hash table [Re: Buggs2008]
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
The same way you wrote to it in the first place:
/hadd <table> <item> <data>
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#206078 - 07/11/08 04:15 AM Re: Re-Write an entry in a hash table [Re: Buggs2008]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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
}

Top
#206080 - 07/11/08 04:27 AM Re: Re-Write an entry in a hash table [Re: Tomao]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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)

Top
#206081 - 07/11/08 04:55 AM Re: Re-Write an entry in a hash table [Re: RusselB]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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.


Edited by Tomao (07/11/08 05:04 AM)

Top
#206083 - 07/11/08 05:52 AM Re: Re-Write an entry in a hash table [Re: Tomao]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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)

Top
#206085 - 07/11/08 08:21 AM Re: Re-Write an entry in a hash table [Re: Tomao]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
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.


Top
#206096 - 07/11/08 04:06 PM Re: Re-Write an entry in a hash table [Re: Buggs2008]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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.

Top
#206097 - 07/11/08 04:06 PM Re: Re-Write an entry in a hash table [Re: Buggs2008]
Buggs2008 Offline
Fjord artisan

Registered: 16/10/07
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.

Top
#206101 - 07/11/08 06:47 PM Re: Re-Write an entry in a hash table [Re: RusselB]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
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'

Top
#206103 - 07/11/08 07:40 PM Re: Re-Write an entry in a hash table [Re: Tomao]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
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!

Top
#206107 - 07/11/08 09:31 PM Re: Re-Write an entry in a hash table [Re: DJ_Sol]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Excuse me for misreading Russel's post, and thanks for the lesson learned.

Top
#206169 - 08/11/08 09:56 PM Re: Re-Write an entry in a hash table [Re: DJ_Sol]
Pivo Offline
Babel fish

Registered: 23/06/08
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

Top