mIRC Home    About    Download    Register    News    Help

Print Thread
#273820 24/02/26 03:46 PM
Joined: Jul 2014
Posts: 317
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 317
Hi guys

Inside the readserv.txt file I have:
Quote
Access list for #Portugal
1 VOP CoOLbiT
2 VOP Koragg
3 VOP Silver_Surfer
4 VOP Corvus
5 VOP PatoBravo
6 QOP TECO
7 QOP James_Bond
8 VOP Fox
9 VOP RSSBot
10 VOP Mastodon
11 QOP James
12 VOP nuke
13 VOP Oasis_
14 AOP Security
15 VOP RadioBot Rรกdio oficial da PTirc

And I have this example code:
Code
alias test {
  if ($1) {
    var %q $read(readserv.txt, w, $+(*,$1,*), 3), %k $readn
    if (%k) echo -sg --> $gettok(%q,2-3,32) $gettok(%q,4-,32)
  }
}

But when I type: /test james, the result should be: --> QOP James, but what it returns is: --> QOP James_Bond

Another example, if I type: /test silver, it shouldn't return anything, but it returns: --> Silver_Surfer

Can anyone figure out what the problem is and what the solution is?

I appreciate anyone who can help wink


TECO
irc.PTirc.org (Co-Admin)
Joined: Jan 2012
Posts: 382
Pan-dimensional mouse
Offline
Pan-dimensional mouse
Joined: Jan 2012
Posts: 382
Try using this script code:
Code
alias readserv {
  if ($1) {
    var %rn 1, %file readserv.txt
    :next | if ($read(%file,ntw,$+(*,$1,*),%rn)) {
      var %rn $readn, %line $read(%file,nt,%rn), %nick $gettok(%line,3,32)
      if (%nick != $1) { if (%rn < $lines(%file)) { inc %rn | goto next } }
      else { echo -sg --> $gettok(%line,2-3,32) $gettok(%line,4-,32) }
    }
  }
}


๐ŸŒ https://forum.epicnet.ru ๐Ÿ“œ irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples
Joined: Sep 2005
Posts: 125
Vogon poet
Offline
Vogon poet
Joined: Sep 2005
Posts: 125
You search for โ€œJamesโ€ and he is at the top of the list, including *. So you should search for James_Bond by entering the full name in /test or move James_Bond to the top of the list.
You can use the variable โ€œsโ€ instead of โ€œw,โ€ but then the nickname would have to be at the beginning of each line.
You can also change the whole thing to $readini to avoid the problem. You can also use hash tables. There are quite a few possibilities.


when no one watching us
we are invisible
Joined: Jul 2014
Posts: 317
TECO Offline OP
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Jul 2014
Posts: 317
Hi Epic,

Thank you for your help.

I liked your code.

Yesterday I finally managed to find a solution, but I had to rewrite the code in a different way.

I did it like this:
Code
alias test {
  if ($1) {
    var %true, %c 2, %file readserv.txt, %l $lines(%file)
    while (%c <= %l) {
      var %q = $read(%file, tn, %c)
      if (%nick == $1) { %true = 1 | echo -sg --> $gettok(%q,2-3,32) $gettok(%q,4-,32) }
      inc %c
    }
    if (!%true) { echo -sg --> $1 is not found! }
  }
}

But I liked your code and I'm going to use it wink

This is the dialog about the purpose of the code:

[Linked Image from i.ibb.co]

Last edited by TECO; 26/02/26 09:43 AM.

TECO
irc.PTirc.org (Co-Admin)

Link Copied to Clipboard