Global variables are variables which are available globally in your code. When you create a variable in a function, like var i = 0;
that is a local variable, and is only available within that function, it is meaningless outside of that function and will likely cause your code to fail. If you want to access the code outside of that function, you should define a global variable outside of all of your functions. That variable can then be access anywhere in your code. Global variables are ideal if you want to set a value, and read it in another function, but don't want to pass it as a parameter.
To create a global variable in Lucid, click the toolbar item 'Setup'. You can now press the '+' button to add as many global variables as you like, and set them to a default value.
If you wish to set a document attribute, you rather than enter a variable name like 'myvar', enter 'document.myvar'. This attribute will be available anywhere you can access the document element in the Javascript DOM tree.