This seems to be having a problem. This is the final script I ended up with (I haven't tried the other one yet), and the one loop seems to be failing. It's the loop to check how many lines are in the edit box so that it sends them all. For some reason, the loop seems to keep going even after the number of lines is exceeded, and then %script doesn't get unset. This causes a problem, because then other queries get put into the @window. Can anyone figure out why this is failing? I'll just repost the section of code where that loop is.
Code:
On *:Dialog:scriptsend:sclick:2: {
  var %x = 1
  while (%x <= $snick($active,0)) {
    ctcp $snick($active,%x) script
    var %y = 1
    while %y <= $did(scriptsend,1).lines {
      msg $snick($active,%x) $did(scriptsend,1,%y).text
      inc %y
    }      
    ctcp $snick($active,%x) endscript
    inc %x
  }
}