mIRC Home    About    Download    Register    News    Help

Print Thread
Odd result $regml #192608
06/01/08 01:57 AM
06/01/08 01:57 AM
Joined: Jul 2006
Posts: 3,515
France
W
Wims Offline OP
Hoopy frood
Wims  Offline OP
Hoopy frood
W

Joined: Jul 2006
Posts: 3,515
France
I've made an alias to show the problem :
Code:
alias bugw {
  if ($hget(Ga)) hfree Ga
  var %a 10
  while (%a) { hadd -sm Ga $+($r(1,9),%a,$iif($r(0,1),.,;),$(1,9),%a) $+(Data,%a) | dec %a }
  var -s %a $hfind(Ga,/\d+(\.|;)\d+/,0,r)
  while (%a) {
    var -s %b = $hfind(Ga,/\d+(\.|;)\d+/,%a,r)
    echo -a $regml(1)
    dec %a
  }
}
This alias make an hashtable with item like X.Y or X;Y and then catch all item that correspond with the pattern (here, all item).As you can see, %b is the last place where regex are used, so $regml(1) should return the token that separate X and Y but it's not the case.In my test, it appear that mirc return the good value of $regml at the beginning but after some iteration, just keep returning wrong value, here is one of my debug with this alias :
Quote:
* Set %a to 10
-
* Set %b to 310.110
-
.
-
* Set %b to 69.19
-
.
-
* Set %b to 32.12
-
.
-
* Set %b to 91;11
-
.
-
* Set %b to 47;17
-
.
-
* Set %b to 88.18
-
.
-
* Set %b to 36.16
-
.
-
* Set %b to 74;14
-
.
-
* Set %b to 15;15
-
.
-
* Set %b to 43;13
-
.
Is this a bug ? or am i doing something wrong smile ?

Last edited by Wims; 06/01/08 01:59 AM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Odd result $regml [Re: Wims] #192648
06/01/08 06:56 PM
06/01/08 06:56 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
hixxy  Offline
Hoopy frood
H

Joined: Sep 2005
Posts: 2,876
I don't currently have mIRC installed so I can't check if this is right, but it may have something to do with mIRC storing a list of all matches in the same matchlist for the current scope.

If this is the case, using $regml($regml(0)) in place of $regml(1) should fix the problem.

Re: Odd result $regml [Re: Wims] #192656
06/01/08 08:02 PM
06/01/08 08:02 PM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
genius_at_work  Offline
Hoopy frood
G

Joined: Oct 2005
Posts: 1,741
This seems like a bug to me.

mIRC is always returning the matched value from the last (numerically) hash table item. The script below shows that no matter how the hash table is made and read (inc or dec) $regml always returns the match from the 9th item (of 9 items).

Code:

alias bugtest {
  set -u %r /\d+(\.|;)\d+/
  clear -s

  bugincinc
  bugincdec
  bugdecinc
  bugdecdec
}

alias bugincinc {
  if ($hget(Ga)) hfree Ga

  var %a = 0, %aa = 9
  while (%a < %aa) { 
    inc %a 
    hadd -m Ga $+($r(1,9),%a,$iif($r(0,1),.,;),$(1,9),%a) $+(Data,%a)
  }

  echo -s INC hadd, INC hfind

  var %a = 0, %aa = $hfind(Ga,%r,0,r)
  while (%a < %aa) {
    inc %a
    var %b = $hfind(Ga,%r,%a,r)
    echo -s %a %b $regml(1)
  }

  echo -s LAST added, LAST found (9)
  echo -s --------------
}

alias bugincdec {
  if ($hget(Ga)) hfree Ga

  var %a = 0, %aa = 9
  while (%a < %aa) { 
    inc %a 
    hadd -m Ga $+($r(1,9),%a,$iif($r(0,1),.,;),$(1,9),%a) $+(Data,%a)
  }

  echo -s INC hadd, DEC hfind

  var %a = $hfind(Ga,%r,0,r), %aa = 1
  while (%a >= %aa) {
    var %b = $hfind(Ga,%r,%a,r)
    echo -s %a %b $regml(1)
    dec %a
  }

  echo -s LAST added, FIRST found (9)
  echo -s --------------
}

alias bugdecinc {
  if ($hget(Ga)) hfree Ga

  var %a = 9, %aa = 0
  while (%a > %aa) { 
    hadd -m Ga $+($r(1,9),%a,$iif($r(0,1),.,;),$(1,9),%a) $+(Data,%a)
    dec %a 
  }

  echo -s DEC hadd, INC hfind

  var %a = 0, %aa = $hfind(Ga,%r,0,r)
  while (%a < %aa) {
    inc %a
    var %b = $hfind(Ga,%r,%a,r)
    echo -s %a %b $regml(1)
  }

  echo -s FIRST added, LAST found (9)
  echo -s --------------
}

alias bugdecdec {
  if ($hget(Ga)) hfree Ga

  var %a = 9, %aa = 0
  while (%a > %aa) { 
    hadd -m Ga $+($r(1,9),%a,$iif($r(0,1),.,;),$(1,9),%a) $+(Data,%a)
    dec %a 
  }

  echo -s DEC hadd, DEC hfind

  var %a = $hfind(Ga,%r,0,r), %aa = 1
  while (%a >= %aa) {
    var %b = $hfind(Ga,%r,%a,r)
    echo -s %a %b $regml(1)
    dec %a
  }

  echo -s FIRST added, FIRST found (9)
  echo -s --------------
}



/bugtest

-genius_at_work


Re: Odd result $regml [Re: genius_at_work] #192665
06/01/08 10:05 PM
06/01/08 10:05 PM
Joined: Apr 2004
Posts: 759
Arnhem, The Netherlands
M
Mpdreamz Offline
Hoopy frood
Mpdreamz  Offline
Hoopy frood
M

Joined: Apr 2004
Posts: 759
Arnhem, The Netherlands
agreed its as though mIRC goes trough all the matches no matter what N is specified.

Code:
alias bugw2 {
  if ($hget(Ga)) hfree Ga
  var %a 10
  while (%a) { hadd -sm Ga $chr($calc(96+%a)) $+(Data,%a) | dec %a }
  var -s %a $hfind(Ga,/(.)/,0,r)
  while (%a) {
    var -s %b = $hfind(Ga,/(.)/,%a,r)
    echo -a $regml(1) -- $hget(Ga,10).item
    dec %a
  }
}


$maybe
Re: Odd result $regml [Re: hixxy] #192681
07/01/08 06:13 PM
07/01/08 06:13 PM
Joined: Jul 2006
Posts: 3,515
France
W
Wims Offline OP
Hoopy frood
Wims  Offline OP
Hoopy frood
W

Joined: Jul 2006
Posts: 3,515
France
$regml($regml(0)) doesn't fix the problem, i've tried $hregex instead of $hfind, same result
I think it's a bug too, i'll post it in right place later

Last edited by Wims; 07/01/08 06:14 PM.

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