Code:
on master:text:!setchan*:#:{ if $2 ischan { set %controlchan $addtok(%controlchan,$2,32) } }  


That'll keep a record of all of the control channels in the one variable, with each channel separated with a space character. Note mIRC has a limitation of about 900 characters for a single variable, so I don't suggest you get rooms/channels with very long names.

I also changed the $chan in the ON TEXT event to # per mIRC help for the ON TEXT event.