mIRC Homepage
Posted By: Diam0nd Several/Multiple Events In One Script - 24/05/13 11:23 PM
Guys, I have a following script:
Code:
on 1:TEXT:*some-criterion*:#some-channel:{
  write file1.txt $gettok($strip($1-),7,32)
}

on $*:TEXT:/some-criterion/:#some-channel:{
  write file2.txt $gettok($strip($1-),7,32)
}

First event triggers fine, but the second never does. However, when I put them separately into 2 different script files, they BOTH work just fine.
So basically what I'm asking is if there's a way to make many/several/multiple events in ONE script file?
And the reason is because I don't want to break it all down into many files, instead concentrating everything in just one file. Makes it easier to track, maintain and update.


Thanks so much in advance! smile
Posted By: Tomao Re: Several/Multiple Events In One Script - 25/05/13 03:58 AM
There's the if-then-elseif method:

on 1:TEXT:*:#some-channel:{
tokenize 32 $strip($1-)
if ($1 == cmd1) {
write file1.txt $gettok($1-,7,32)
}
elseif ($1 == cmd2) {
write file2.txt $gettok($1-,7,32)
}
elseif ($1 == cmd3) {
write file3.txt etc..
}
...

etc...

You may want to use tokenize 32 $strip($1-) so you don't have to use $strip() repeatedly in every trigger.
Posted By: sparta Re: Several/Multiple Events In One Script - 25/05/13 05:47 AM
You should use the [ code ] and [ /code ] , and I added one } at the end for you wink

Code:
on 1:TEXT:*:#some-channel:{
  tokenize 32 $strip($1-)
  if ($1 == cmd1) {
    write file1.txt $gettok($1-,7,32)
  }
  elseif ($1 == cmd2) {
    write file2.txt $gettok($1-,7,32)
  }
  elseif ($1 == cmd3) {
    write file3.txt etc..
  }
}
...

etc...


Posted By: Diam0nd Re: Several/Multiple Events In One Script - 25/05/13 09:57 AM
Originally Posted By: sparta
You should use the [ code ] and [ /code ] , and I added one } at the end for you wink

Code:
on 1:TEXT:*:#some-channel:{
  tokenize 32 $strip($1-)
  if ($1 == cmd1) {
    write file1.txt $gettok($1-,7,32)
  }
  elseif ($1 == cmd2) {
    write file2.txt $gettok($1-,7,32)
  }
  elseif ($1 == cmd3) {
    write file3.txt etc..
  }
}
...

etc...




Guys, thank you both SO much for your replies and kind help!
I'm still struggling with it, to be frank though.

Let me illustrate what I'm trying to do here. I want an event to be triggered on the following phrase:
Code:
.year.word.word.word-

(year in the standard yyyy format, meaning 1999, 2000, 2001, etc.)

Then:
- IF year is 198X, write to file 1
- IF year is 199X, write to file 2
- IF year is 200x, write to file 3
- IF year is 201X, write to file 3
- Etc.

So basically what I CAN'T get to work is the if checking against a regex that would look something like this:
Code:
\.198\d\.word\.word\.word-
\.199\d\.word\.word\.word-
etc.

(I checked the regex here and it seems to be valid: http://regexpal.com/)


Does anyone have an idea how to make that workable?
I tried playing around with $regex(), but the script just doesn't work for some reason frown

Any ideas/suggestions would be much, much appreciated! smile
Posted By: Tomao Re: Several/Multiple Events In One Script - 26/05/13 01:18 AM
I believe this is what you've attempted to do based on the example you showed me above:
Code:
on $*:text:/^\.(19[89][0-9]|200[0-9]|201[0-3])\.(.+\056){3}.+\-$/iS:#some-channel:{
if ($regml(1) isnum 1980-1990) { write file1.txt ... }
elseif ($regml(1) isnum 1991-1999) { write file2.txt ... }
elseif ($regml(1) isnum 2000-2009) { write file3.txt ... }
elseif ($regml(1) isnum 2010-2013) { write file4.txt ... }
}
© mIRC Discussion Forums