Re-Write an entry in a hash table
#206076
07/11/08 03:04 AM
|
Joined: Oct 2007
Posts: 214
Buggs2008
OP
Fjord artisan
|
OP
Fjord artisan
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
starbucks_mafia
Hoopy frood
|
Hoopy frood
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
Tomao
Hoopy frood
|
Hoopy frood
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: 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
RusselB
Hoopy frood
|
Hoopy frood
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: 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
Tomao
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
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
RusselB
Hoopy frood
|
Hoopy frood
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
DJ_Sol
Hoopy frood
|
Hoopy frood
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. 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
Buggs2008
OP
Fjord artisan
|
OP
Fjord artisan
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
Buggs2008
OP
Fjord artisan
|
OP
Fjord artisan
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
Tomao
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
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
DJ_Sol
Hoopy frood
|
Hoopy frood
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
Tomao
Hoopy frood
|
Hoopy frood
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
Pivo
Babel fish
|
Babel fish
Joined: Jun 2008
Posts: 58 |
As far as I know Khaled only explained this switch in the variables section of the help file. What about... The -s switch makes the command display the result. /help /hmake
|
|
|
|
|