I'm not sure what to tell you, but somewhere you must have goofed up, as this works perfectly for me.
I just tested it, and it worked the way you wanted it to.
From the way it sounds, you must have the "var" lines unseperated. This is the only reason I can think of for it to message the channel with "var = !latest"
Does yours look like this:
var %network = network , %schan = #channel var %text = $1 , %i = 1
It needs to look like this:
var %network = network , %schan = #channel
var %text = $1 , %i = 1