|
|
Joined: Jul 2014
Posts: 317
Pan-dimensional mouse
|
OP
Pan-dimensional mouse
Joined: Jul 2014
Posts: 317 |
Hi guys Inside the readserv.txt file I have: 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: 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_BondAnother example, if I type: /test silver, it shouldn't return anything, but it returns: --> Silver_SurferCan anyone figure out what the problem is and what the solution is? I appreciate anyone who can help 
TECO irc.PTirc.org (Co-Admin)
|
|
|
|
|
Joined: Jan 2012
Posts: 382
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Jan 2012
Posts: 382 |
Try using this script 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) }
}
}
}
|
|
|
|
|
Joined: Sep 2005
Posts: 125
Vogon poet
|
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
Pan-dimensional mouse
|
OP
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: 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  This is the dialog about the purpose of the code: ![[Linked Image from i.ibb.co]](https://i.ibb.co/jPjZh0fr/Screenshot-1.png)
Last edited by TECO; 26/02/26 09:43 AM.
TECO irc.PTirc.org (Co-Admin)
|
|
|
|
|