no thats really a common mistake... if you want that value to work 100% then you need to do this instead
Global Coffee as integer
function MyFunction()
Coffee=15
endfunction
however if you do
Dim Coffee(0) as integer
function MyFunction()
Coffee(0)=15
endfunction
that'll always work

god knows why, because arrays should really be just sections of memory like the other values.
as long as you remember a global value declared with global, a local/private value declared as a local ... and then use no designation for values that are really going to be used in that loop
so like
Coffee as integer
do
Coffee=Coffee+1
Coffee=WrapCoffee(Coffee)
loop
function WrapCoffee( Coffee )
if Coffee>=10 then Coffee=0
endfunction Coffee
that'll work a treat

reason for encapsulating the funcitons is so you don't have to think ip new names for things all the time.
Within the Epic battle of the fates the Shadow and the Angel will meet. With it will harbinger the very fight of good vs evil!