mIRC Homepage
Posted By: maroon $nick().color = 0 for no-such-nick - 25/11/20 10:10 AM
When $nick() uses a not-present nick or an invalid index number with the .color prop, it returns 0 instead of $null, indicating the color is white

//echo -a $nick($chan, nosuchnick).color should be null instead of zero

For this next example I had to insert an extra 9999 check because it was difficult to get it to respond to control break to exit the infinite loop

//var %i 1 | while ($nick($chan,%i).color != $null) { echo -a i= %i nick= $nick($chan,%i) color= $v1 | inc %i | if (%i > 9999) halt }

edit: the .idle property is also returning zero for these same cases
Posted By: Khaled Re: $nick().color = 0 for no-such-nick - 25/11/20 10:57 AM
Quote
When $nick() uses a not-present nick or an invalid index number with the .color prop, it returns 0 instead of $null

This behaviour is actually present in many identifier properties. Some return a default value if no match is found, others return $null. The behaviour is somewhat arbitrary - probably based on what a particular scripter requested at the time it was implemented. In this case, this has always returned a default value.

Quote
edit: the .idle property is also returning zero for these same cases

The same applies to this property.

In general, if you want to check if something exists, you need to check for the item itself ie. $nick($chan,nick), without properties. In many cases, a return of $null for a property can be perfectly valid.
© mIRC Discussion Forums