mIRC Home    About    Download    Register    News    Help

Print Thread
How much use if statement in an event? #255148 26/09/15 03:19 PM
Joined: Jul 2015
Posts: 25
Q
quanbhvn Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jul 2015
Posts: 25
I have a script like this:
Code:
on *:TEXT:*:#Mychan: {
if (*atext* iswm $1-) { msg $chan text No 1 }
elseif (*btext* iswm $1-) { msg $chan text No 2 }
elseif (*ctext* iswm $1-) { msg $chan text No 3 }
elseif (*dtext* iswm $1-) { msg $chan text No 4 }
...
...
...
elseif (*ztext* iswm $1-) { msg $chan text No 99 }
}


Thus, have limit to the number of "elseif" allowed to use?

Although it still works, but I think the syntax is not correct.

Please help me to present a more accurate script.

Thank you.

Last edited by quanbhvn; 26/09/15 03:25 PM.
Re: How much use if statement in an event? [Re: quanbhvn] #255151 26/09/15 06:21 PM
Joined: Dec 2008
Posts: 1,511
westor Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
You can use unlimited 'elseif' statement and is the only way in that code that your are trying to do.

Re: How much use if statement in an event? [Re: westor] #255209 30/09/15 03:41 AM
Joined: Jul 2015
Posts: 25
Q
quanbhvn Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jul 2015
Posts: 25
Originally Posted By: westor
You can use unlimited 'elseif' statement and is the only way in that code that your are trying to do.


I've tried, it seems it works not very accurate. I've used 200 elseif statement. sometimes it works, sometimes not. If my statement is wrong, it will never work. So I think my statement was correct. How to use 200 or even 2000 statement "elseif" but the script still works correctly?

Re: How much use if statement in an event? [Re: quanbhvn] #255213 30/09/15 06:44 AM
Joined: Jul 2015
Posts: 25
Q
quanbhvn Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jul 2015
Posts: 25
I'm pretty sure there are many other ways and smarter but i can't think something better for now. Please help me. Thank you.

Re: How much use if statement in an event? [Re: quanbhvn] #255214 30/09/15 08:45 AM
Joined: Feb 2015
Posts: 243
O
OrFeAsGr Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
If you have a list of text matches and they're not some kind of text commands that may need further if statements you can save the matches on an .ini file and their values should then be the replies.
In case you haven't used .ini before type /help /writeini
/help $readini

Last edited by OrFeAsGr; 30/09/15 08:47 AM.