What are function local variables and arrays?Function local variables and arrays are variables and arrays that belong to the function in which they are decalred as local. They exist only while the function in which they have beed declare is being executed or while a function called by the function in which they have been declared is being executed.
They are often refered to simply as locals.
Locals allow functions to be written in a modular style. A function that uses a local does not need to worry about the same variable or array being used by another function or within the mainline code. The compiler will keep variables and arrays that are declared local hidden from other functions and also the mainline code. This means that is it possible for many different variables called X and Y to exist throughout a program and they will not interfere with each other. The compiler knows which RAM location is being refered to within a function even when several variables exist throughout the program with the same name.
A function that uses locals is far easier to transplant from one working program to another, than a function (or subroutine) that uses just global variables and arrays.
Using locals allows the compiler to better utilise RAM. This is because the compiler can arrange for functions to share RAM used by local variables and arrays in such a way that they cannot interfer with each other. While minimising the amount of RAM actually used.
Many BASIC compilers do not support the use of locals at all.