This should work for you:
Thanks for that. It works but it seems like I have to leave unticked the option in mirc "rejoin channels on connect" which I'd rather not have to do. Maybe I confused the situation when I mentioned that I unticked that in a previous post, but that was only a temporary solution.
Is it possible to adjust the script and have it work with a similar delay option but still tick the option in mirc to "rejoin channels on connect" ?
TIA.