mIRC Home    About    Download    Register    News    Help

Print Thread
#52903 07/10/03 09:52 PM
Joined: Jun 2003
Posts: 114
T
Thray Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Jun 2003
Posts: 114
I made a sockbuf alias that sends text out in lines so that no single line will exceed a certain number of characters.. but of course color doesn't carry over.

I am trying to find a way to make the color carry over to each line, but I can't think of a way to do this despite looking in the help file for a while now.
Is there a way to check a variable for the presence of $chr(3) (the color code character), then get the LAST occurence of it in the string, plus up to 2 numbers that come after it?

Code:
  
alias sockbuf {
  var %buf = $null, %string = $2-, %num = 0
  while (%string) {
    %buf = $gettok(%string,1,32)
    %string = $deltok(%string,1,32)
    if (%num != 0) { %buf =  $+ $chr(32) $+  $+ %buf }
    while ($len(%buf) < 75 && %string) {
      %buf = %buf $gettok(%string,1,32)
      %string = $deltok(%string,1,32)
    }
    if ($len(%buf) > 75) { %string = $instok(%string,$gettok(%buf,$numtok(%buf,32),32),1,32) | %buf = $deltok(%buf,$numtok(%buf,32),32) | sockwrite -n $1 %buf }
    else { sockwrite -n $1 %buf }
    inc %num
  }
}


-------------
I am the self-appointed God of needlessly complex mIRCscript.
#52904 07/10/03 10:46 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
I could swear there was an identifier for this already, but I couldn't think of it so try this instead:

Code:
get_last_col {
  ;Usage: $get_last_col(<text>)
  ; returns colour last colour codes contained in string (minus colour control code itself)
  ; .pos property returns position of first number
  ; .lpos property returns position of last number
  var %re = /(\d{1,2}(?:,\d{1,2})*)(?:[^]*)$/
  !.echo -q $regex(get_last,$$1,%re)
  if ($prop == pos) return $iif($regml(get_last,1).pos,$ifmatch,0)
  elseif ($prop == lpos) return $iif($regml(get_last,1).pos,$calc($ifmatch + $len($regml(get_last,1)) - 1),0)
  return $iif($regml(get_last,1),$ifmatch,$null)
}


It works with background colours aswell, so text 04,03blah will return 04,03.

Edit: Forgot to add .lpos property
Edit: Fixed .lpos property (I'll get this alias right sooner or later blush)

Last edited by starbucks_mafia; 07/10/03 10:54 PM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard