Since when can't you use $1 in a while loop?

/test 5 works just fine here (mIRC v6.16)
Code:
alias test {
  var %i = 1
  while (%i < $1) {
    echo TEST: %i ; $1
    inc %i
  }
}

As for his script: $rand instead of rand, a space after the while and it might have worked...