Ok this is the final code. Everything works and there are no errors (assuming the user does not try to mess up on purpose). I didnt do error checking because it doesnt matter for this little experiment.

alias chanduper {
  var %cd.chan = $?="What channel do you want to copy?"  
  var %cd.num = $?="How many copies?"
  var %cd.num2 = %cd.num
  var %cd.op = $?!="Deop in all of the channels?"
  while (%cd.num) {
    var %cd.chan = $instok(%cd.chan,,2,46)
    var %cd.chan = $remove(%cd.chan,.)
    var %cd.join = $addtok(%cd.join,%cd.chan,44)
    dec %cd.num
  join %cd.join
  if (%cd.op) {
    inc %cd.num
    echo -ae %cd.join
    echo -ae %cd.num
    while (%cd.num <= %cd.num2) {
      mode $gettok(%cd.join,%cd.num,44) -o $me
      inc %cd.num