Solved the problem :-). I've included all of the functions at the top of the code before the arrays were defined, which made the compiler think that the arrays were never defined.
Many thanks for all your help Prof and Becky - very much appreciated.
Many thanks for all your help Prof and Becky - very much appreciated.