Ok, although it works, it's more or less incorrect.
mIRC/sockread isn't missing the line, it sees it but since it reads line by line, the $crlf is removed on purpose.
your $calc() is going to always give -1 whenever the binvar is empty, and $bvar(&,-1,1) does give 0.
Note that you're checking the penultimate character with your $calc, if for some reasons you had a nul byte 0, your $bvar could return 0 and it would make it fail, although it's probably ok to guess you'll never have a nul byte there lol.

But you should be checking that the binvar itself is empty with if ($bvar(&mybinvar,0) == 0)

As a matter of fact, your on sockread event is *wrong* as well, because you're asking for a line, but if no line is present, you request the data anyway, in your situation it's not a problem, because in any case you're going to write whatever you have to the file, but if you were looking for a specific line in the response, like it's often the case with socket script, if you were lagging for example, only a small portion of the line you want would be available, so your script wouldn't match that line, and you would then read the rest of the line later, ending up never having the full line being checked, I described this here: http://en.wikichip.org/wiki/mirc/commands/sockread
in your situation above you can make sure you read an empty line by checking $sockbr, which should be 2 while $bvar(,0) is 0, but you did read 2 bytes.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel