Home > FAQ, How To's > How To Use Global Variables

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)

For Example:


‘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’.

For Example:





If you wish to change a global variable value, just add the ‘=’ operator and write the new value, for example:



    Vars[“PointLimit”])= Answer(CurrQues);


That’s it!

Visit us at: http://www.dooblo.net

Categories: FAQ, How To's
  1. September 4, 2012 at 9:07 am

    It’s not clear so far, whether these “Vars” can be exported to data file or they live only inside current record and after submitting vanish without trace

  2. rontal
    July 23, 2012 at 12:26 pm

    Yes this is totally fine using it inside a global variable instead of writing it everytime

  1. July 19, 2012 at 7:40 am
  2. August 9, 2012 at 2:19 pm
  3. February 26, 2013 at 4:15 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: