okies:
Global Variables:
Global Variables are where data can be read and written at any point in the program - in the main loop, or in functions, or anywhere else.
Local Varialbes:
Local Variables are data that can only be accessed in its particular part of the program, for instance, if you have a local variable in the main loop, you cannot read it in a function without making it an input parameter of the function. You can however read and write to the variable in subroutines (goto & gosub commands) because they are essentially part of the main program and are not seperated in any way except for location.
In functions, local variables can only be accessed in that function, and will not affect any variable in the main program, even if there is an identicly named variable to one in the program outside the function. however functions can pass out 1 variable into the main program, and can take variables from the main program in the form of parameters. eg:
do
inc outside#
outside#=test(outside#)
loop
function test(inside#)
inside#=inside#+0.2
endfunction inside#
In this code the function takes in the variable 'outside#' which is local to the main loop, and uses its value to set an internal variable called 'inside#' within the function.
Then after incrementing the 'inside#' variable by 0.2 the function then outputs the 'inside#' variable into the main loop where it is taken by the 'outside#' variable.
Hope that helps
Ask if u want anything explained further.