mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2012
Posts: 301
Epic Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 301
The identifier $sline(window,0) - returns nothing if there are no selected lines in the list.
It is logical to assume that the answer should be = 0. The returned numeric value is meaningful in some cases. For example, when using an enumeration in a loop "While".

For check:
Code
//sline -r #test | echo -a $sline(#test,0)

Returns: * /echo: insufficient parameters


Would like to the returned response was as ยซ0ยป (exact number) to be able to take the necessary steps to highlight a specific line in the window list:
Code
if ($nick(#test,0) > 0 && $sline(#test,0) == 0) { /sline -l #test 1 }

Otherwise, it is likely that the script with a similar string "IF" condition will not bring the desired result or will crashes. Thanks.


๐ŸŒ http://forum.epicnet.ru ๐Ÿ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I agree with such a change.

It should probably be the case that $sline(@NoSuchWindow,0) and $line(@NoSuchWindow,0) and $nick(#NoSuchChannel,0) return $null as they currently do, but if the window exists, it seems reasonable that $sline should return the zero just like $line does for an empty @window. An exception to returning $null from non-existent things is how $lines(NoSuchFIle.txt) returns zero instead of $null. I don't think the zero-vs-null behavior should differ depending on whether a window is a @listbox or not.

I doubt this affects most scripts, because they would usually use the boolean check "while ($sline(@window,0))" instead of comparing the value to zero.

In a more general case, when a script needs to defend against the possibility that a variable or identifier can be null, and wants to treat that null the same as zero, there's a couple additional ways of handling it.

if (%variable == 0)
becomes
//var %variable $null | if (0 $+ %variable == 0) echo -a match

if (%variable > 0)
becomes
//var %variable $null | if (%variable !<= 0) echo -a match

You can also use $calc(%variable) but that has the side-effect of having text strings also treated as zero.

Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks this issue has been fixed for the next version.


Link Copied to Clipboard