Yes, please upload your script here (or email it) and I'll try it out and see if it sheds any light on the problem.
I've been struggling to simplify it much, unfortunately. I don't have to do too much to it before it starts working! I'll keep at this for a little while longer, but then create an OSS message - as you say, it may well be that the simplest thing is for you to look at my system.
Thanks for your help so far.
Steve.