mIRC Homepage
Posted By: Rand /sockread -c - 26/09/07 01:10 PM
Could we possibly get a switch, such as -c, to "keep" the $crlf's? I would find it beneficial to not have to do some strange coding to put these back into the binvar itself.

Granted, it's been a long night, so maybe I'm overlooking something a little more simple. *shrug*

This is basically what I have to resort to at the moment:

Code:
on *:sockread:test:{
  sockread -n &test
  if (!$sockbr) {
    sockread -fn &test
    if (!$sockbr) return
  }
  else {
    var %l = $bvar(&test,0) + 1
    bset &test %l 13 10
  }
  bwrite thetest.txt -1 -1 &test
}
on *:sockclose:test:{ run thetest.txt }


If we could preserve the crlfs, I would be able to write directly to the file without any worry:
Code:
on *:sockread:test:{ sockread -c &test | bwrite thetest.txt -1 -1 &test }
Posted By: Collective Re: /sockread -c - 26/09/07 02:52 PM
The /sockread -n switch reads one line at a time, that's what -n is for. If you don't want to do that then don't use -n.
Posted By: Rand Re: /sockread -c - 26/09/07 04:37 PM
Hrmn, strange.

I could have sworn I attempted to do:

sockread &blah
bwrite ... &blah

Tried it again just now and it worked.


I must have, in the wee hours of this morning (4am-ish), thought something wasn't working when I tried it. But I think I've discovered the reason why I didn't think it worked:

The page I was using the plain sockread &blah on, had one major massive line on it, the rest of the webpage only had $cr terminated lines. So doing a sockread &blah would show only a couple massive lines of text when looking at the created file. But using sockread, in my alternative code, in the way I did above, was basically converting the $cr's to $crlf's.

Well hrmn. :P Guess I can't ask for a switch to auto convert $crs to $crlfs eh.

Also, why is it that when you do: sockread 4000 &blah, $bvar(&blah,0) doesn't *always* return 4000 (it returns many other amounts in my tests and only a few of those are 4000) ? I thought that was supposed to force a 4000 byte sockread? ... I'm going to assume it has something to do with the speed at which you download it *shrug*
© mIRC Discussion Forums