Using answer codes when referencing an answer in the survey scripts is the best practice in many cases when scripting a survey.
Why? When question answers change along the way, new answer might be added or the order of the existing answers might change -
The answer index will change but the answer code would remain the same (in case you have not changed the ‘lock answer automatic coding’ property - http://support.dooblo.net/entries/84203545-How-To-Lock-Answer-Codes-on-Answers-list-Scale-update) which means that you will not have to change your scripts when making those changes!
We have many functions that can be used in order to use answer codes instead of answer indexes when scripting here are a few common examples:
- SelectedAnswerCode(int QuestionIndex)- returns the code of the answer selected in the QuestionIndex question.
- GetAnswerChoiceIdxByCode(int inQuesIdx, string inAnswerCode) - Returns the answer index according to the matching answer code given.
- AnswerCode(int inQuesIdx, int inAnswerIdx) - returns the answer code of an answer according to the given inAnswerIdx.
For more functions and information you can view our complete function library: http://support.dooblo.net/entries/22356261-SurveyToGo-Built-In-Functions-Hand-Book
Visit us at: http://www.dooblo.net