Variables are declared explicitly in your script. These variables are displayed as parameters in the specification tree.
Unlike in most script languages, a variable's scope is not really determined by where you declare it. From anywhere in your script, you can access a variable by using the ../.. and ? operators. After the script is finished running, the variable declared in your script still exists as a document parameter.