mIRC Homepage
Posted By: Plornt Stripping spaces - 06/10/10 04:01 AM
I need to send spaces over a socket with some other data but the spaces get deleted and only one is left. Is there anyway to stop mirc from stripping excess spaces?

Also mirc 7.1 takes significantly longer to process text files oddly.
Posted By: jaytea Re: Stripping spaces - 06/10/10 07:02 AM
Originally Posted By: Plornt
I need to send spaces over a socket with some other data but the spaces get deleted and only one is left. Is there anyway to stop mirc from stripping excess spaces?


you have to store that data in a binary variable. here's a snippet you can use that employs this method:

Code:
alias sockwritesp {
  var %unlikely = $chr(28)
  if ($sock($1)) {
    bset -tc &a 1 $replace($2, $chr(32), %unlikely) $+ $crlf
    breplace &a $asc(%unlikely) 32
    var %i = 1
    while ($pos($utfencode($1), %unlikely, %i)) {
      bset &a 1 $asc(%unlikely)
      inc %i
    }
    sockwrite $1 &a
  }
}


you can use it as $sockwritesp(<sockname>, <data>) to send that data with a trailing CRLF and multiple spaces intact.

Originally Posted By: Plornt

Also mirc 7.1 takes significantly longer to process text files oddly.


can you provide a minimal example of a snippet of code with which you notice a significant difference?
Posted By: Plornt Re: Stripping spaces - 06/10/10 09:27 PM
Amazing, than you very much smile

AAbout the other thing, I havent got any code to hand but I have a 1200 line quote file and I am while looping through them for what a user searches then out putting the line number. On mirc 6.35 It could do it within seconds (from what I recall) however on mirc 7.1 the thing freezes for a whole minute and somtimes even ping timeout.
Posted By: drum Re: Stripping spaces - 06/10/10 09:48 PM
Originally Posted By: Plornt
Amazing, than you very much smile

AAbout the other thing, I havent got any code to hand but I have a 1200 line quote file and I am while looping through them for what a user searches then out putting the line number. On mirc 6.35 It could do it within seconds (from what I recall) however on mirc 7.1 the thing freezes for a whole minute and somtimes even ping timeout.


Instead of using a while loop, use the $read "w" switch and $readn. For example:

Code:
alias findquote {
  noop $read(quotes.txt,nw,* $+ $1- $+ *)
  return $readn
}


$findquote(something) will return the line number of the first line that contains "something" (or 0 if there was no match).

If that isn't robust enough for what you need, /filter would probably be a good place to start.

Either method should be MUCH faster than what you were using!
Posted By: Plornt Re: Stripping spaces - 07/10/10 07:59 PM
Ah thank you again... Totally forgot about the w switch...

Also one last thing, as im not any good at all with bin vars (I try to learn them but really dont understand them) is there a way of sending a null character over the socket?

An hex example of what I need to send:

00 07 50 6C 6F 72 6E 74 62 6F 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 61 6B 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0D 0A 00

EDIT: Dont wory edited your code above and actually understood them :P Figured it out, ended up replacing a character I knew I would never use and then changing it to 00

Okay new problem FF in hex (255 in dec/chr) is actually sending C3 (195) which it shouldnt. Is there a way of doing that?

(Sorry I now know this isnt a bug but yea, still need help, thanks to all that have helped so far :))
Posted By: Voglea Re: Stripping spaces - 08/10/10 02:55 AM
Code:
alias hex2bvar {
  tokenize 32 $1
  bunset &bvar
  while ($0) {
    bset &bvar $calc($bvar(&bvar,0) + 1) $base($1,16,10)
    tokenize 32 $2-
  }
  return &bvar
}


/sockwrite $sockname $hex2bvar(00 07 50 6C 6F 72 6E 74 62 6F 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 61 6B 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0D 0A 00)
Posted By: Wims Re: Stripping spaces - 08/10/10 03:27 AM
You can't return a &bvar this way, here $hex2bvar will return "&bvar", you could do something like :

Quote:
alias sending {
bset &bvar 1 $regsubex($2-,/(\S+)/g,$base(\1,16,10))
sockwrite $1 &bvar
bunset &bvar
}

and use /sending sockname value value1 valueN
Posted By: Voglea Re: Stripping spaces - 08/10/10 04:10 AM
it's okay wink

//echo -a $bvar($hex2bvar(ff ff),1-) = 255 255
Posted By: drum Re: Stripping spaces - 08/10/10 10:31 AM
Originally Posted By: Wims
You can't return a &bvar this way, here $hex2bvar will return "&bvar", [...]


The way mIRC handles binary variables is very primitive. All binary variables are globally defined and persist until the entire script finishes processing. (In other words, even though the binary variable was first created from inside the $hex2bvar call, the variable will still exist and can be accessed after returning to the alias that called $hex2bvar.

Since the variable is globally defined, returning the NAME of the binary variable is fine. The /sockwrite command will be able to read the contents of that binary variable.

By the way, if you are making heavy use of binary variables you may want to be careful about overlapping binary variable names since they are defined globally!
Posted By: Wims Re: Stripping spaces - 08/10/10 05:54 PM
I know how binary variable works, the way he used them, by returning the name of the variable, left me thinking that he was thinking that mIRC has types, I was tired sorry.
© mIRC Discussion Forums