Global variables

Global variables can be used when you require a variable to be visible by all of the program. To transform a variable into a global simply add the keyword global prior to its declaration.

global value as integer = 1

do myFunction ( )
sync ( ) loop
function myFunction ( ) print ( value ) endfunction

Now that the variable value has been declared as global it becomes visible in the function myFunction.

Globals have their place and can be useful, but at the same time can contribute to making a large program unwieldy, as it can often lead to confusion with one variable being able to be modified in multiple locations throughout a program. It's probably better to pass data around your program where possible by using parameters and return values in functions, which is perhaps an easier way to manage data and keep track of what is happening.