mIRC Homepage
Posted By: RRX $hget(hash,item,&binvar) inconsistent behaviour - 23/08/09 09:28 AM
if you do:
var %bytes = $hget(hash,item,&binvar)
when the item does not exist, %bytes becomes 0 (correct) but mIRC does not alter &binvar if the binary variable already existed. This isn't consistent with for example var %a = %b where the variable %b does not exist, there it clears the content of variable %a

Another inconsistency is that /hadd hash item %a, with %a nonexistent, creates the item in the hash (with no corresponding data), but if you do /hadd -b hash item &binvar, where &binvar is nonexistant, it halts on error with insufficient parameters.

This behaviour in the binvar usage isn't expected if you come from using common variables so causes bugs for unapparent reason, especially the first inconsistency.

I understand that changing the behaviour leading to inconsistency 1 will break scripts that started to rely on the non-altering in case the hash item doesn't exist (although it may be quite rare since the command would overwrite as soon as the binary item is there).
But change or not, the help should at least mention this.
$hget(name/N, item, &binvar)
Assigns the contents of an item to a &binvar.
->
$hget(name/N, item, &binvar)
Assigns the contents of an item to a &binvar, if the item does not exist, &binvar is unaltered.
© mIRC Discussion Forums