mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
Tested on mIRC version 6.16 (and below) Windows 98 & 2K...

ok I wrote a pack alias to repack addresses like the ones in your browsers address bar now.. characters are unpacked to a base 16 number and given a % symbol before it. thus %2F = / etc... This alias it seems $ifmatch uses my found match and evaluates it thinking its a variable.

alias pack {
var %rx.1 = $replace($1-,$chr(43),$chr(32)) , %rx.2 = $regex(%rx.1,/(%..)/g)
var %x = 0 | while ($regml(%x)) { inc %x | var %rx.1 = $replace(%rx.1,$ifmatch,$chr($base($remove($ifmatch,$chr(37)),16,10))) }
return %rx.1
}

this alias which I have taken out $ifmatch works FLAWLESSLY....

alias pack {
var %rx.1 = $replace($1-,$chr(43),$chr(32)) , %rx.2 = $regex(%rx.1,/(%..)/g)
var %x = 0 | while ($regml(%x)) { inc %x | var %rx.1 = $replace(%rx.1,$regml(%x),$chr($base($remove($regml(%x),$chr(37)),16,10))) }
return %rx.1
}

Not a bad bug.. simple work around, but I thought there was a problem with my code and it boggled me for HOURS! DAYS! im glad I finally fixed it tho..

Last edited by Talon; 22/08/04 11:14 AM.
Joined: Mar 2004
Posts: 457
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Mar 2004
Posts: 457
i thought $ifmatch was supposed to be used in IFs, not whiles, hence the use of the word if in it.
Plz do correct me if i'm wrong someone cuz i'm too lazy to test.

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
//tokenize 32 hello world | while ($0) { echo -a $ifmatch | tokenize 32 $2- }


New username: hixxy
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
a while is the same as an if.. can you not do while (%x < 5) same as if (%x < 5) ? Its an expression $ifmatch works, if it didnt I wouldnt have used it smile

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
The bug is not in $ifmatch, but rather in your code. You're setting %x to 0 and then using $regml(%x), or in other words checking $regml(0) - which returns the number of matches, not the first match. In your second alias however you're incrementing %x before the main peice of code so that when $regml(%x) is evaluated inside the code it is the equivalent of $regml(1).

Your code can be fixed by initiating %x to 1 and incrementing after the main body of code in the loop:
Code:
alias pack {
  var %rx.1 = $replace($1-,$chr(43),$chr(32)) , %rx.2 = $regex(%rx.1,/(%..)/g)
  var %x = [color:blue]1[/color]
  while ($regml(%x)) {
    %rx.1 = $replace(%rx.1,$ifmatch,$chr($base($remove($ifmatch,$chr(37)),16,10)))
    [color:blue]inc %x[/color]
  }
  return %rx.1
}


Note: I also removed one use of /var to make the code more efficient, although it won't affect the code either way.

Last edited by starbucks_mafia; 22/08/04 05:57 PM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
ummm I like to read my code easily so thats why I used multiple instances instead of crowding one line with a big string... I see what your saying and it does make sense why it failed now.. This is the way I have always done loops, it explains a lot now.. Grr I feel like an idiot lol


Link Copied to Clipboard