mIRC Homepage
Posted By: Nobodi hadd -u0 - 29/06/03 08:56 PM
Seems "hadd -u0 table item data" doesn't unset after the script finishes.
Posted By: Prizm Re: hadd -u0 - 29/06/03 09:49 PM
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.
Posted By: Nobodi Re: hadd -u0 - 29/06/03 09:56 PM
The -uN switch unsets the item after N seconds.

Last time i checked 0 was a valid number.
Posted By: codemastr Re: hadd -u0 - 29/06/03 11:07 PM
Well then perhaps you should check again, because as your test proved, it is _not_ a valid number.
Posted By: RG_ Re: hadd -u0 - 29/06/03 11:17 PM
Sometimes 0 = never wink
Posted By: Raccoon Re: hadd -u0 - 30/06/03 12:37 AM
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
Posted By: codemastr Re: hadd -u0 - 30/06/03 03:10 PM
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.
Posted By: Raccoon Re: hadd -u0 - 30/06/03 04:41 PM
Sometimes people like to write really complex scripts, very modular. And there are times when you simply don't have access to 'the end'.
Posted By: codemastr Re: hadd -u0 - 30/06/03 04:43 PM
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?
Posted By: pheonix Re: hadd -u0 - 30/06/03 04:45 PM
because hashtables are faster for big/many values?
Posted By: codemastr Re: hadd -u0 - 30/06/03 05:21 PM
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.
Posted By: Raccoon Re: hadd -u0 - 30/06/03 06:01 PM
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
Posted By: qwerty Re: hadd -u0 - 01/07/03 12:34 AM
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.
© mIRC Discussion Forums