Just noticed you said thats invalid syntax, Not sure what you mean, mIRC will be happy with it...
Do you mean you can't use that for some particular reason?
Edit: If you can't use that code, be more specific and show a few examples of the actual strings you will get