Have a look at the $N identifiers (/help $1-). $1 is the first word, $2 the second word etc. Example:
Code:
; "&" is a wildcard for a word
on *:text:!countto &:#: {
; only count if the second word is a valid number
if ($2 isnum 1-) {
var %a = 1, %b = $2
while (%a <= %b) {
msg # %a
inc %a
}
}
}