mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2014
Posts: 2
K
kripp Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
K
Joined: Apr 2014
Posts: 2
After using $regex, I'll get a certain number of matches, for example $regml(0) = 28
Is there a command to print all matches (at the same time - for msg or echo): $regml(1) $regml(2) ... $regml(28) without having to do it manually?

Thanks in advance!

Last edited by kripp; 22/05/14 05:34 AM.
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
There is no such command, it's not required, just make your own:

Code:
Alias regdump {
var %a 1
echo -a regml values for the regex call $iif($1 != $null,named $1,with the default name)  $+ :
while ($regml($1,%a)  != $null) {
echo -a %a $+ . $qt($v1)
inc %a
} 
} 


/regdump [name]

Last edited by Wims; 22/05/14 08:09 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Apr 2014
Posts: 2
K
kripp Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
K
Joined: Apr 2014
Posts: 2
just a small correction on this line:
Code:
while ($regml(%a) != $null) { 

and it worked nicely.

I was able to get what I wanted (all in the same line) with this:

Code:
 while ($regml(%a) != $null) {
    set %list $addtok(%list,$v1,32)
    inc %a
  }
echo -a %list


Wouldn't know how to start without you, so thank a lot!

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Right, I originally wrote it thinking that, with a $null name, it would take it as the default (same as $regml(N), with no name).
As far as getting everything on one line, you don't need to 'set' the variable, which will create a global variable (not destroyed at the end), would be better to use 'var', to create a local variable (destroyed at the end).
Using $addtok is not a good idea because $addtok won't add twice the same token while you do want to get the same token if it's there.
Finally, getting everything on one line might not be as clear as having each result on a new line but that's up to you. But keep in mind that could trigger the line length limit of mIRC (a command + its parameters cannot be more than 4150 characters)

Here is a modified version:

Code:
Alias regdump {
  var %o 0,%v,%r
  if ($1 == -o) {
    %o = 1
    tokenize 32 $2-
  }
  var %a 1,%p % $+ a
  if ($1 != $null) %p = $1 $chr(44) %p
  echo -a $!regml values for the regex call $iif($1 != $null,named $qt($1),with the default name)  $+ :
  while ($regml( [ %p ] ) != $null) {
    %v = $v1
    if (%o) %r = $+(%r,$str($chr(160),6),%a $+ . $qt(%v))
    else echo -a %a $+ . $qt(%v)
    inc %a
  }
  if (%a == 1) echo -a No result.
  elseif (%o) echo -a $right(%r,-6)
}
/regdump -o [name] -- the -o switch will get all the result displayed on one line with some spaces between each result, otherwise it's like before, each result on its own line.

Last edited by Wims; 22/05/14 09:43 AM.

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

Link Copied to Clipboard