Humm i am not sure about your question.
But for what i could figured out you are traying to reconnect to a server when you have been disconnected and joines the proper channel etc etc etc.
Why you donīt use the options that mirc have already.
Alt + o --> Connect --> Options --> "Reconnect on disconnection"
Note:. Donīt forget to enable the connect retry out too
Them to join the channel you can use the "Channel list" icon the icon that you have on mirc.
With that you can choose to coonnect automatcaly when join a network ( choosed by you ).
Hope this can help.
If this was not what you ask for it, sorry...
Not what I asked for at all. But, no need to be sorry for that! At least you wanted to help.