mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2007
Posts: 14
D
Diam0nd Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Sep 2007
Posts: 14
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


mIRC v7.32 REGISTERED
Plain, no scripts
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
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...




if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Sep 2007
Posts: 14
D
Diam0nd Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Sep 2007
Posts: 14
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

Last edited by Diam0nd; 25/05/13 10:34 AM.

mIRC v7.32 REGISTERED
Plain, no scripts
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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 ... }
}


Link Copied to Clipboard