mIRC Home    About    Download    Register    News    Help

Topic Options
#255148 - 26/09/15 04:19 PM How much use if statement in an event?
quanbhvn Offline
Ameglian cow

Registered: 14/07/15
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.


Edited by quanbhvn (26/09/15 04:25 PM)

Top
#255151 - 26/09/15 07:21 PM Re: How much use if statement in an event? [Re: quanbhvn]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
You can use unlimited 'elseif' statement and is the only way in that code that your are trying to do.
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#255209 - 30/09/15 04:41 AM Re: How much use if statement in an event? [Re: westor]
quanbhvn Offline
Ameglian cow

Registered: 14/07/15
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?

Top
#255213 - 30/09/15 07:44 AM Re: How much use if statement in an event? [Re: quanbhvn]
quanbhvn Offline
Ameglian cow

Registered: 14/07/15
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.

Top
#255214 - 30/09/15 09:45 AM Re: How much use if statement in an event? [Re: quanbhvn]
OrFeAsGr Offline
Fjord artisan

Registered: 01/02/15
Posts: 243
Loc: Greece
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


Edited by OrFeAsGr (30/09/15 09:47 AM)

Top