mIRC Homepage
Posted By: bodo0815 $ifmatch question - 03/10/05 07:28 PM
Code:
on *:TEXT:!search *:#p: {
  msg # 7:: Limit of 5 results
  var %line = 1,%i = 0
  while ($read(nick.txt,nw,$+(*,$$2-,*),%line)) { 
    msg # 7:: 11[10MA7T10CH11]7 $ifmatch
    %line = $readn + 1
    inc %i
    if %i == 5 { break }
  }
}

how can i msg to $chan if nothing was found

thx bodo
Posted By: Lpfix5 Re: $ifmatch question - 03/10/05 08:02 PM
Quote:
Code:
on *:TEXT:!search *:#p: {
  msg # 7:: Limit of 5 results
  var %line = 1,%i = 0
  while ($read(nick.txt,nw,$+(*,$$2-,*),%line)) { 
    msg # 7:: 11[10MA7T10CH11]7 $ifmatch
    %line = $readn + 1
    inc %i
    if %i == 5 { break }
  }
[color:red] if ($read($nick.txt,nw,$+(*,$$2-,*),%line) == $null)  { msg $chan No Match Found }[/color]
}

how can i msg to $chan if nothing was found

thx bodo
Posted By: bodo0815 Re: $ifmatch question - 03/10/05 08:13 PM
thx but it does not seems to work :-(
Posted By: Kelder Re: $ifmatch question - 03/10/05 08:24 PM
$readn is 0 if no match found, but if there are 2 entries in the text, $readn will be 0 after the while.
$v1 contains the last test value of the while, but that is always $false after the while (else the while loop wouldn't have ended)
$ifmatch is deprecated and should be replace by $v1 in new scripts. I also changed some of the code to make it less lines, and made the counter start at 0, you'll see why right away smile
Best option is to check the loop counter: if %i > 0 then the loop has passed one time...

Code:
on *:TEXT:!search *:#p: {
  msg # 7:: Limit of 5 results
  var %line = 0,%i = 0
  while ((%i < 5) && ($read(nick.txt,nw,$+(*,$$2-,*),%line))) { 
    msg # 7:: 11[10MA7T10CH11]7 $v1
    var %i = %i + 1, %line = $readn + 1
  }
  if (!%i) msg $chan Nothing found...
}
Posted By: bodo0815 Re: $ifmatch question - 03/10/05 08:40 PM
thx
© mIRC Discussion Forums