mIRC Home    About    Download    Register    News    Help

Print Thread
Stripping spaces #226539 06/10/10 04:01 AM
Joined: May 2010
Posts: 29
P
Plornt Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
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.

Last edited by Plornt; 06/10/10 04:02 AM.
Re: Stripping spaces [Re: Plornt] #226545 06/10/10 07:02 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
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?


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: Stripping spaces [Re: jaytea] #226561 06/10/10 09:27 PM
Joined: May 2010
Posts: 29
P
Plornt Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
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.

Re: Stripping spaces [Re: Plornt] #226562 06/10/10 09:48 PM
Joined: Dec 2002
Posts: 344
D
drum Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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!

Re: Stripping spaces [Re: drum] #226569 07/10/10 07:59 PM
Joined: May 2010
Posts: 29
P
Plornt Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
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 :))

Last edited by Plornt; 07/10/10 10:39 PM.
Re: Stripping spaces [Re: Plornt] #226584 08/10/10 02:55 AM
Joined: Nov 2009
Posts: 81
V
Voglea Offline
Babel fish
Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
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)

Re: Stripping spaces [Re: Voglea] #226585 08/10/10 03:27 AM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Stripping spaces [Re: Plornt] #226586 08/10/10 04:10 AM
Joined: Nov 2009
Posts: 81
V
Voglea Offline
Babel fish
Offline
Babel fish
V
Joined: Nov 2009
Posts: 81
it's okay wink

//echo -a $bvar($hex2bvar(ff ff),1-) = 255 255

Re: Stripping spaces [Re: Wims] #226592 08/10/10 10:31 AM
Joined: Dec 2002
Posts: 344
D
drum Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
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!

Re: Stripping spaces [Re: drum] #226602 08/10/10 05:54 PM
Joined: Jul 2006
Posts: 3,702
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,702
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.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net