mIRC Homepage
Posted By: Bramzee if (lastword == X) ?? - 08/04/17 03:08 PM
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.
Posted By: Masoud Re: if (lastword == X) ?? - 08/04/17 03:10 PM
Code:
$gettok($1-,$0,32)
Posted By: Bramzee Re: if (lastword == X) ?? - 08/04/17 03:33 PM
Thank you smile
You've been a HUGE help.
Posted By: FroggieDaFrog Re: if (lastword == X) ?? - 08/04/17 05:09 PM
Other options:
Code:
$($ $+ $0,2)
$ [ $+ [ $0 ] ]
Posted By: maroon Re: if (lastword == X) ?? - 20/04/17 04:40 AM
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)
© mIRC Discussion Forums