Thanks H.F, it's working now.
There was an error with my script (it was based on the one from the help files)

Cheers