Code:
on *:text:*:#:{
  tokenize 32 $strip($1-)
  if $chan == #channel {    var %text = $4  }
  elseif $chan == #next {    var %text = $8  }
  else {    var %text = $5  }
  %text = $gettok(5text,-1,47)
  echo -a %text
}


When comparing the name of a channel to $chan, you can only use ==
There is no way for mIRC to know if #channelA is greater or lesser than #channelB, but it can tell if #channelA matches #channelB (using a text match comparison).