What i am trying to achieve is to make an array local such that every time the function is called, it dimensions a new array. In this program it stores the value 2 into an array then it calls itself again and stores 3 into an array. It prints this value then returns back because the function finishes. Then it prints the array from the first calling. This should be 2 but it says 3. This means that the array isn't truly local because it always takes the same value as long as it's in the function and doesn't matter if you've called it again or not. Is there a way of making it truly local or do I have to try something else? Also, how do you make a variable (not array) global?
rem Make hi a global array so it is always the same
dim hi(4)
hi(0)=2
rem Call the function
do_something(0)
rem Make sure it doesn't run through the function again once the program finishes
end
rem Recursive function to test out local array
function do_something(endd)
rem Dimension a local array
dim hello(1)
rem Change values
hello(0)=hi(0)
hi(0)=hi(0)+1
rem Call itself but make sure it doesn't become an indefinate loop
if endd=0 then do_something(1)
rem See if values are as expected
print hello(0)
rem Return
endfunction