mIRC Home    About    Download    Register    News    Help

Print Thread
if (lastword == X) ?? #260368 08/04/17 03:08 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Is there a way to set a check for the last word in an on TEXT? Ex:

Code:
on *:text:*:#: {
  if (lastword == X) {
   msg # ...
  }
  else return
}


obviously I know that I could use $1, $2, $3, etc checks... But that's not what I need. Because the text could be anything from $2 to $8 so I need a way to check if the last word is a certain word.

Re: if (lastword == X) ?? [Re: Bramzee] #260369 08/04/17 03:10 PM
Joined: Mar 2010
Posts: 144
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 144
Code:
$gettok($1-,$0,32)


Nothing...
Re: if (lastword == X) ?? [Re: Masoud] #260370 08/04/17 03:33 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Thank you smile
You've been a HUGE help.

Re: if (lastword == X) ?? [Re: Bramzee] #260371 08/04/17 05:09 PM
Joined: Apr 2010
Posts: 923
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 923
Other options:
Code:
$($ $+ $0,2)
$ [ $+ [ $0 ] ]


I am SReject
My Stuff
Re: if (lastword == X) ?? [Re: Bramzee] #260430 20/04/17 04:40 AM
Joined: Jan 2004
Posts: 1,200
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,200
Another way that returns last token is using -1 instead of $0

Also, depending on what text you're dealing with, sometimes a line of text contains a colorcode at the very end to ensure that a background color highlights past the final letter, so these methods can possibly return a colorcode instead of an actual word. You'd want to strip color codes before checking for the last word:

Code:
$gettok($strip($1-),-1,32)