Home > FAQ, Getting Started, How To's, Studio Manual, Survey Creation, Survey Logic > Script Writer’s Function Hand-Book

Script Writer’s Function Hand-Book

This document contains most of the common every-day usable functions in SurveyToGo.
Explained, demonstrated and elaborated.
This document is directly connected to us, and is constantly updated with new functions and info by our professional team, stay updated!
A Survey Script Writers True Gem!

FilterAnswersByAnswers \ FilterTopicsByAnswers:

Explanation: This function gets a target question index and a source question.
It filters the Current Question’s answers through, according to the answers chosen in the source questions specified.

Input: Gets 2 Parameters

1st Parameter: The Target Question.

2nd Parameter: A Boolean value – ‘true’ for showing answers selected, ‘false’ for showing answers not selected.

3rd Parameter: The Source Questions.

Output: Filters the specified answer index’s

Example of How to write:
FilterAnswersByAnswers(CurrQues,true,QRef(15));
FilterAnswersByAnswers(CurrQues,
true,QRef(15),QRef(16),QRef(17));
FilterTopicsByAnswers(3,
false,QRef(2));


SelectedAnswerText:

Explanation: This function gets a target question index and returns the text of the answer selected

Input: Gets 2 Parameters.

1st Parameter: The Target Question index.

2nd Parameter: A Boolean value – ‘true’ for getting the ‘Other Specify’ input too, ‘false’ for not getting the ‘Other Specify’ input text.

Output: Text of the answer selected

Example of How to write:
SelectedAnswerText (5,true);
SelectedAnswerText (2,
false);


Answer:

Explanation: This function gets a target question index of only single choice questions such as:
(Single-Choice, Numeric, Open Ended, Scale, Expression)
and returns its selected answer index.

Input: Gets 1 Parameters

1st Parameter: The Target Question.

Output: Returns its selected answer index

Example of How to write:
Answer(CurrQues);


Contains:

Explanation: This function gets a target question index of only Multi-Selection questions and an answer index, and checks if this answer was selected.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer Index.

Output: returns ‘True’ if the given answer was selected – returns ‘False’ if the given answer was not selected.

Example of How to write:
Contains(2,1);


SetAnswerVisible \ SetTopicVisible:

Explanation: This function gets a target question index, a answer\topic index, and a Boolean value (true/false), and shows\hides the given answer\topic.

Input: Gets 3 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer\Topic Index.

3rd Parameter: A Boolean value. (‘true’ for showing – ‘false’ for hiding)

Output:

Example of How to write:
SetAnswerVisible(CurrQues,2,false);
SetTopicVisible(CurrQues,4,
false);


AnswerChoice:

Explanation: This function gets a target question index of a ‘Single-Choice-Grid’ question only, and a topic index.
it returns the index of the selected answer in the given topic.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Topic Index.

Output: returns an index of the selected answer in the given topic within the given multi-topic question.

Example of How to write:
AnswerChoice(CurrQues,3);
AnswerChoice(1,2);


NumOfSelectedChoices:

Explanation: This function gets a target question index of a multi-selection question only, and returns the number of selected answers.

Input: Gets 1 Parameters

1st Parameter: The Target Question Index.

Output: returns the number of selected answers.

Example of How to write:
NumOfSelectedChoices(CurrQues);


GetTopicCount:

Explanation: This function gets a target question index of a Single-Choice Grid question only, and returns the number of topics.

Input: Gets 1 Parameters

1st Parameter: The Target Question Index.

Output: returns the number of topics.

Example of How to write:
GetTopicCount(CurrQues);


AnswerIter:

Explanation: This function gets a target question index of questions that are within a loop of only single choice questions such as:
(Single-Choice, Numeric, Open Ended, Scale, Expression)
and an iteration index.
It returns the answer of the target question in the given Iteration Index.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Specific Iteration Index.

Output: Returns its answer in the given iteration index within the loop.

Example of How to write:
AnswerIter (CurrQues,
3);

AnswerIter (CurrQues,IterationIndex);

*NOTE:IterationIndex Represents the current iteration when running within a loop, so it’s value is set according to the iteration which is currently running.


ContainsIter:

Explanation: This function gets a target question index of questions that are within a loop of only multi-selection question, an answer index and an iteration index.
It checks if the given answer was selected in the target question within the given Iteration Index.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Specific Iteration Index.

3rd Parameter: The Specific Iteration Index.

Output: returns ‘True’ if the given answer was selected in the given iteration – returns ‘False’ if the given answer was not selected in the given iteration index.

Example of How to write:
ContainsIter(CurrQues,
3,7);

ContainsIter (CurrQues,2,IterationIndex);

*NOTE:IterationIndex Represents the current iteration when running within a loop, so it’s value is set according to the iteration which is currently running.


Random():

Explanation: This function gets an integer and returns a random number between the 0 and the integer number given minus 1.

Input: Gets 1 Parameter.

1st Parameter: Maximum number. (Please note that the number generated is between zero till a number that is 1 less than the maximum number given)

Output: returns a random integer within the given range.

Example of How to write:
Random(5);

Random(732);


SelectedAnswerText():

Explanation: This function gets a target question index and a Boolean and returns a text string with all the answers chosen in the given question index, separated with a comma.

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: ‘true’ for including any ‘Other Specify’ text, ‘false’ for not including any ‘Other Specify’ text.

Output: returns a text string with all the answers chosen in the given question index, separated with a comma.

Example of How to write:
SelectedAnswerText(12,true);

SelectedAnswerText(CurrQues,false);


SetAnswer():

Explanation: This function gets a target question index and a target answer index and sets this answer is chosen in the given question index

Input: Gets 2 Parameters

1st Parameter: The Target Question Index.

2nd Parameter: The Target Answer Index

Output: doesn’t return anything, just sets the answer given.

Example of How to write:
SetAnswer(5,2);
SetAnswer(CurrQues,8);

  1. November 12, 2012 at 8:13 am

    “GetSelectedAnswerText” does not exist, there is “SelectedAnswerText” instead

  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: