How To Use Global Variables
If you wish to hold data in a global variable which will be available to fetch from every single place in your survey – Global variables are the answer.
Global Variables are used to store different data, making it available through all of your survey.
This how to will instruct on how to create global variables and how to use them.
How Global Variables Are Construced?
Global variable need to have to parameters:
1. The Key (the name of the variable).
2.The Value (Can be a number, a text input or a Boolean value)
‘Vars’ is basically declaring that this is a global variable.
Where To Create A Global Variable?
In any place you want across your survey (start & end scripts\advanced scripts\ survey init code) you can declare
How To Create A Global Variable?
Here are real examples of how you can create global variables:
As you can see, we have declared the ‘Vars’ component in order to make the system ‘know’ it is global.
We used the square bracelets, and placed the key name within.
Then we set a value to our keys.
How To Access A Global Variable?
In any place in your survey which you need to have any use of one of your global variables, you can just write it with its name, for example:
Like this you can use the value they hold in rules,scripts,etc’.
// DO SOME NICE CODE
If you wish to change a global variable value, just add the ‘=’ operator and write the new value, for example:
Visit us at: http://www.dooblo.net