mIRC Home    About    Download    Register    News    Help

Print Thread
#131718 03/10/05 07:28 PM
Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
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

#131719 03/10/05 08:02 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
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


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
#131720 03/10/05 08:13 PM
Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
thx but it does not seems to work :-(

#131721 03/10/05 08:24 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
$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...
}

#131722 03/10/05 08:40 PM
Joined: Apr 2005
Posts: 72
B
Babel fish
OP Offline
Babel fish
B
Joined: Apr 2005
Posts: 72
thx


Link Copied to Clipboard