I have moved this thread to the tutorials section as I think it deserves to be available long term. Some of the replies and examples are very informative.

Thanks everyone who contributed so far.