Overview
When scripting you often use functions which reference questions. These functions require you to specify the question index however using question indexes can make your script difficult to understand and maintain and in some cases can also be dangerous unless using QRef which again makes the code even more harder to understand. Therefore we’ve introduced the ability to reference questions using their Variable Names instead. To use variable names in your script:
Step 1: Check that the feature is turned on for your survey
Step 2: Using the variable names in your survey script
Step 1: Check that the feature is turned on for your survey
To check that the feature is turned on for your survey, open the survey and then:
- Make sure that the “Disable question symbols” option is not checked:
- In case it is checked, un-check it.
Step 2: Using the variable names in your survey script
Once the option is turned on, you can now simply reference the question variable names in your script wherever a question index is expected. The engine has now defined all the question variables as internal variables that you can use. For example, we have a question called “Gender”:
Lets now write a start script in Q2 that prompts a message if the answer to the gender question was 1 (male):
As soon as we start writing “GE” the autocomplete already shows us there is a GENDER variable that we can reference, so now the script can look like so:
And so instead of using the question index (1) we used the question variable name (GENDER) which makes our script code much more readable. In addition, the GENDER variable name will maintain its index even if the question is moved from being index 1 to index 13 for example. This means there is now need to use QRef when using the variable names which is a huge plus!
That’s it!
Visit us at: http://www.dooblo.net
Comments
Please sign in to leave a comment.