mIRC Home    About    Download    Register    News    Help

Print Thread
/sockread -c #186781
26/09/07 01:10 PM
26/09/07 01:10 PM
Joined: Feb 2005
Posts: 342
R
Rand Offline OP
Fjord artisan
Rand  Offline OP
Fjord artisan
R

Joined: Feb 2005
Posts: 342
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 }

Re: /sockread -c [Re: Rand] #186789
26/09/07 02:52 PM
26/09/07 02:52 PM
Joined: Dec 2002
Posts: 3,138
London, UK
C
Collective Offline
Planetary brain
Collective  Offline
Planetary brain
C

Joined: Dec 2002
Posts: 3,138
London, UK
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.

Re: /sockread -c [Re: Collective] #186797
26/09/07 04:37 PM
26/09/07 04:37 PM
Joined: Feb 2005
Posts: 342
R
Rand Offline OP
Fjord artisan
Rand  Offline OP
Fjord artisan
R

Joined: Feb 2005
Posts: 342
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*