The following code illustrates an odd problem with arrays in functions.
The array element 'a(1)' contains 1, using this as the index on 'b()' outside of the function sets the correct element, inside the function 'a(1)' still contains 1 but using it as an index on 'b()' sets element 'b(0)' instead.
I can get round it by assigning a(1) to another variable first, but I thought I should bring it to peoples attention.
dim a(1)
dim b(1)
a(1) = 1
b(1) = 10
setb()
print str$(b(1)) ; "," ; str$(b(0))
wait key
function setb()
print str$(a(1))
b(a(1)) = 20
endfunction