mIRC Home    About    Download    Register    News    Help

Print Thread
#247294 27/07/14 02:51 AM
Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
Hello, I am working with binary variables, but when connecting to web,the server send me a too long line and do not know how to extract the data, is there any way short very long lines and leave them short to make: if (title isin %data) or example , or another way to manipulate lines 1024 lines?

regards

Joined: Jul 2014
Posts: 48
A
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
I think you can check for regular expressions, and also iswm compare. I'm not sure exactly how to use them, but I have seen them done before

Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
is that regular expressions do not fail to understand, I find no documentation in Spanish who can explain me good translations not totally be understandable, because to read the information of the binary variable (found in data.txt, to make read tells me the very line too long.

Joined: May 2014
Posts: 36
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 36
I'll put the example I'm doing, I made the extraction of data loki12583 me as I said is this:

Code:
on *:sockread:test:{
  var %headerfile = $sockname $+ .header.txt
  var %datafile = $sockname $+ .data.txt
 
  if (!$sock($sockname).mark) {
    var %header | sockread %header
    while (%header != $null) {
      write %headerfile %header
      sockread %header
    }
    if ($sockbr) {
      sockmark $sockname $true
    }
  }
  if ($sock($sockname).mark) {
    sockread &read
    while ($sockbr) {
      bwrite %datafile -1 -1 &read
      sockread &read
    }
  }
}


up there gives me a file STORE2336190.data.txt and good, are all captured data via web, but with very long lines, but when I try to read them in any way can not, try this:

Code:
alias searchdata {
  set %zxcline 1
  while ($read(STORE2336190.data.txt,%zxcline) != $null) {
    if (dragon iswm $read(STORE2336190.data.txt,%zxcline)) { echo -s 000DATA  $read(STORE2336190.data.txt,%zxcline) }
    echo -s ALL $read(STORE2336190.data.txt,%zxcline)
    inc %zxcline
  }
  echo -s no data
}


just read the first line, which is <! doctype html>
but then tells me that line too long, would there be another way to read those long lines? what are my options?

Last edited by Perl; 27/07/14 11:07 AM.
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Well as you can see there is a limit (4150 bytes) in mIRC in general.
You are using /sockread &name, which will read by default 4096 bytes into the binary variable, so if you were to try to use the text inside that binary like in a iswm comparison, it would work:

Code:
sockread &read
if (dragon iswm $bvar(&read,1-).text) echo -a ALL $v2
instead of writting to a file.

You're writting everything to a file and then you are reading line by line, and apparently you end up with a line being too long. It is possible to read line by line into a binary variable using the -n switch in /sockread. That would basically be the same as what you have, except that this time you have the line (possibly too long) into a binary variable (no fail on $read). You can then use $bfind to try to match manually something in the line, you can also try this little alias, which will remove all <tag> from a binary variable ($nohtml for binvar), hopefully this can be used in your situation to reduce the length of the line and, if you're not looking for some <tag> (in your while loop, you're looking for 'dragon'), it can be used to make a match using the usual tool like the iswm operator etc:
Code:
alias nohtml& {
  var %pos
  while ($bfind($1,1,<).text) {
    %pos = $v1
    if ($bfind($1,$calc(1+%pos),>).text) bcopy -c $1 %pos $1 $iif($v1 != $bvar($1,0),$calc(1+$v1) -1,$v1 0)
    else bcopy -c $1 1 $1 1 $calc(%pos -1)
  }
  while ($bfind($1,1,>).text) bcopy -c $1 1 $1 $calc(1+$v1) -1 
}
You would use that in something like
Code:
if ($sock($sockname).mark) {
    sockread -fn &read
    noop $nohtml&(&read)
    if ($bvar(&read,0) < 4096) echo -a >  $bvar(&read,1-).text
    else echo -a > $bvar(&read,1,4096)
    ; and eventually you can do here if (dragon iswm $bvar(&read,1,4096).text) echo -a ALL $v2
}



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

Link Copied to Clipboard