mIRC Home    About    Download    Register    News    Help

Print Thread
#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.

Joined: Mar 2010
Posts: 146
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 146
Code:
$gettok($1-,$0,32)


Nothing...
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.

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Other options:
Code:
$($ $+ $0,2)
$ [ $+ [ $0 ] ]


I am SReject
My Stuff
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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)


Link Copied to Clipboard