mIRC Home    About    Download    Register    News    Help

Print Thread
hadd -u0 #33053 29/06/03 08:56 PM
Joined: Dec 2002
Posts: 191
N
Nobodi Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
Seems "hadd -u0 table item data" doesn't unset after the script finishes.

Re: hadd -u0 #33054 29/06/03 09:49 PM
Joined: May 2003
Posts: 177
P
Prizm Offline
Vogon poet
Offline
Vogon poet
P
Joined: May 2003
Posts: 177
Why are you using the -u0 switch and the first place? You don't need it. It's not working because 0 is not a valid parameter.

Re: hadd -u0 #33055 29/06/03 09:56 PM
Joined: Dec 2002
Posts: 191
N
Nobodi Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
The -uN switch unsets the item after N seconds.

Last time i checked 0 was a valid number.

Re: hadd -u0 #33056 29/06/03 11:07 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Well then perhaps you should check again, because as your test proved, it is _not_ a valid number.

Re: hadd -u0 #33057 29/06/03 11:17 PM
Joined: Dec 2002
Posts: 19
R
RG_ Offline
Pikka bird
Offline
Pikka bird
R
Joined: Dec 2002
Posts: 19
Sometimes 0 = never wink

Re: hadd -u0 #33058 30/06/03 12:37 AM
Joined: Feb 2003
Posts: 2,681
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,681
Interesting. An unfortunate inconsistency as /set -u0 works fine and is in heavy use. If a script wanted to convert to hashtables for speed, this inconsistancy wouldn't make it very easy.

Yes, I can see very valid uses of hadd -u0, especially with an existing hashtable filled with non-u0 items. hadd -u0 might be used as a method of erasing an item after the event ends since hadd overwrites by default, something you'd otherwise need a /timer to do.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: hadd -u0 #33059 30/06/03 03:10 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Why would you need a timer? Just include a /hdel at the end of the alias. Just like we used to use /unset at the end of an alias before local variables were added.

Re: hadd -u0 #33060 30/06/03 04:41 PM
Joined: Feb 2003
Posts: 2,681
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,681
Sometimes people like to write really complex scripts, very modular. And there are times when you simply don't have access to 'the end'.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: hadd -u0 #33061 30/06/03 04:43 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Well the way I'm seeing it is a hash table is not local scope. The hash table continues to exist once the script ends. So why exactly would you use a hash table to store temporary values when /var already does a fine job of it?

Re: hadd -u0 #33062 30/06/03 04:45 PM
Joined: May 2003
Posts: 2,265
P
pheonix Offline
Hoopy frood
Offline
Hoopy frood
P
Joined: May 2003
Posts: 2,265
because hashtables are faster for big/many values?


new username: tidy_trax
Re: hadd -u0 #33063 30/06/03 05:21 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Ok well let me rephrase, why would you be using a hash table that was created outside that alias to store temporary values? Meaning, if you just need a place to store a lot of values why don't you just /hmake when the alias begins and /hfree when the alias ends? Why are you using a hash table that was created elsewhere? It makes no sense to me.

Re: hadd -u0 #33064 30/06/03 06:01 PM
Joined: Feb 2003
Posts: 2,681
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,681
Alright, here's a example. It's just one of many.

You have a list of user names and various tokenized information about them stored in a hash table.

You have a nested looping function which is going line by line through, lets say, a log file... and for each line, it has to loop through (or query) various users from the hash table. Lets say this script example is auditing the users based on Joins and Parts to a channel log. For each Join the first loop hits, it either adds the user to the list, or maintains their existing tokens if already in the list. For each Part, it slates the user to be removed (-u0) if they don't Join again later on in the log. At the end of the log, all users that have been slated for removal fall off the list, while all users who had Joined again lost the -u0 flag in the subsequent hadd.

The above example CAN be done in other ways, but this example is suppose to unlock your mind to the potential of some methods out there that can benifit from this. Be it an existing script that is being converted from Variables to Hash Table, or a new script with an entirely unique and valid use for -u0 flagging.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: hadd -u0 #33065 01/07/03 12:34 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
An unfortunate inconsistency as /set -u0 works fine and is in heavy use. If a script wanted to convert to hashtables for speed, this inconsistancy wouldn't make it very easy.

Exactly... and to make this transition even harder, /hinc kills the timer set with a previous /hadd -uN, unlike /inc.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com