You forgot to increment the variable
Code:
alias hopall {
  var %chan.num = $chan(0), %i = 1
  while %i <= %chan.num {
    hop -c $chan(%i)
    inc %i
  }
}


Being able to remember what rooms you're in so that you can use /partall and then re-join is a poor way of doing this, since the information would be best stored in a variable, and, therefore, is limited by the 900 (or so) character limit for variables.

I would not recommend using that method.