Question type variable (askiascript)

In AskiaScript, a question type variable contains all the information and actions that can be executed on a question, chapter or loop.

The special keyword CurrentQuestion provides useful access to the start question of the routing or the question attached to the inline script context.

To create a question type variable, use askiadesign to create a question, chapter or loop in the survey structure.

In this topic:

See also:

Properties

AllIterations

Available from version 5.3.5.

Available only for loops. Returns an array of the specified question at all possible iterations. Takes into account the entire parent loop hierarchy.

Returns an array of Question.

This method iterates as follows:

Top loop first response
   Sub loop first response
       Sub sub loop first response
       sub sub loop second response
       ...
   Sub loop second response
       Sub sub loop first response
       sub sub loop second response
       ...
   ...
Top loop second response
   Sub loop first response
       Sub sub loop first response
       sub sub loop second response
       ...
   Sub loop second response
       Sub sub loop first response
       sub sub loop second response
       ...
   ...
...

Examples
' q1 is a question inside only one loop level with 3 iterations

q1.AllIterations.Count ' => 3
q1.AllIterations[1].IsLastIteration ' => false

q1.AllIterations[1].CurrentIteration.Index ' => 1
q1.AllIterations[2].CurrentIteration.Index ' => 2
q1.AllIterations[3].CurrentIteration.Index ' => 3

q1.AllIterations[3].IsLastIteration ' => true
' q5 is a question inside a loop of loop (loop1 with 2 iterations, loop2 (sub-loop) with 3 iterations)
Dim i
dim str = "" 
For i = 1 To q5.AllIterations.Count
   str = str + q5.AllIterations.ToString() + "n" 
Next

' str will looks like the following (some fragments has been remove for readability):
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":1,"loop2":1}}
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":1,"loop2":2}}
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":1,"loop2":3}}
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":2,"loop2":1}}
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":2,"loop2":2}}
'{"shortcut":"q5","type":"single","isInLoop":true,"iterations":{"loop1":2,"loop2":3}}

↑ Top of page ↑

AllValues

Only available for questions in a loop. Returns a flattened array, with all values of the question in the loop.

Examples
 ' Q1 is a single question inside a loop with 3 iterations
Q1.AllValues ' => {3; 5; 2}
 ' Q2 is a multiple question with 3 responses mandatory inside a loop with 3 iterations
Q2.AllValues ' => {3;1;4;2;5;1;4;5;2} 

 ' => Here 3;1;4 are the answers of Q2 for the first iteration of the loop and so on.
 ' Q3 is an open-ended question inside a loop with 3 iterations
Q3.AllValues ' => {"hello"; "hi"; "goodbye"}
 ' Q4 is a numeric question inside a loop with 3 iterations
Q4.AllValues ' => {32.5; 47.1; 0}
 ' Q5 is a single question inside a loop of loop with respectively 3 and 2 iterations
Q5.AllValues ' => {5;3;3;4;1;2}} 

 ' => Here 5;3 are the answers of the first iteration of the outside loop and 5 the answer of the first iteration of the inside loop
 ' Q6 is a multiple question inside a loop of loop with respectively 3 and 2 iterations
Q6.AllValues ' => {5;3;4;2;1;4;1;2;3;2;4;3;3;2;1;4;1;2} 

 ' => Here 5;3;4;2;1;4 are the answers of the first iteration of the outside loop and 5;3;4 the answer of the first iteration of the inside loop
 ' Q7 is an open-ended question inside a loop of loop with respectively 3 and 2 iterations
Q7.AllValues ' => {"hello";"world";"hi";"people";"goodbye";"folks"} 

 ' => Here "hello";"world" are the answers of the first iteration of the outside loop and "hello" the answer of the first iteration of the inside loop
 ' Q8 is a numeric question inside a loop of loop with respectively 3 and 2 iterations
Q8.AllValues ' => {13.5;12;0;5;8.3;9} 

 ' => Here 13.5;12 are the answers of the first iteration of the outside loop and 13.5 the answer of the first iteration of the inside loop

↑ Top of page ↑

Answers

Returns the list of selected responses in the selected order.

Returns a Collection of Responses.

Example
brands.Answers ' => {<Response::3#Pepsi> ; <Response::4#7up>}

↑ Top of page ↑

AvailableAnswers

Available from version 5.5.2

Returns the list of available loop items in the selected order and taking into account the MaxVisibleIterations properties of the loop.

If you have 3 iterations on the loop and you set the MaxVisibleIterations to 2 then it will return the 2 first iterations on the first page then the last one on the second page.

This property is mainly used for the ADC in order to limit the number of visible items of the loop on a page. It return dynamically the N number of items per page based on the value given at the MaxVisibleIterations.

If this property is used outside the loop then it reacts as the .Answers property.

Returns a Collection of Loop Responses.

Example

Loop (with Pepsi, 7up and Coca cola and MaxVisibibleIterations set to 2)
	Question (Yes, No)
Firt page:
loop.AvailableAnswers ' => {<Response::3#Pepsi> ; <Response::4#7up>}
Second page:
loop.AvailableAnswers ' => {<Response::5#Coca cola>}

↑ Top of page ↑

AvailableResponses 

Returns the list of available responses in the visible order.

Returns a Collection of Responses.

Example
brands.AvailableResponses ' => {<Response::3#Pepsi> ; <Response::2#Coca-cola>}

↑ Top of page ↑

ChildQuestions

Available from version 5.5.0.

Returns the list of direct child questions.

Returns a collection of Questions.

Examples
 gender.ChildQuestions

↑ Top of page ↑

Comments

Available from version 6.5.0.

Returns the comments of the question.

Returns a String.

Example
Q1.Comments ' => There is a question after

↑ Top of page ↑

CurrentIteration

Available only for loops. Returns the response of the loop that references the current iteration.

Returns a Response.

Example
Loop1.CurrentIteration ' => <Response::1#Brand1>
 ' You can also use it for the comparison
If Loop1.CurrentIteration = 1 Then [...]
' 
If Loop1.CurrentIteration.EntryCodeStr = "UK" Then [...]

↑ Top of page ↑

Decimals

Indicates the number of digits allowed for a decimal value.

Returns a Number.

For open-ended questions, this method returns the maximum allowed length. When no decimal is allowed, it returns 0.

Examples
age.Decimals  ' => 0
temperature.Decimals ' => 1

↑ Top of page ↑

DKEntry

Available from version 5.3.3.

Indicates a special entry used to specify the "don't know" answer.

Returns a String.

Example
age.DKEntry ' => "999"

↑ Top of page ↑

Errors

Available from version 5.4.1.

Returns the list of errors during the interview associated with the question. This allows ADCs to indicate if there is an error associated with a specific entry, as opposed to the page as a whole.

See also: Error

Returns an Array of Errors.

Example
CurrentQuestion.Errors.Count ' => 0
CurrentQuestion.Errors[1].Key ' => "expected_answer"
CurrentQuestion.Errors[1].Message ' => "A response is expected for question 'q1'"
{% If CurrentQuestion.Errors.Count Then %}
<ul class="question-errors"><li>{%= CurrentQuestion.ShortCaption %}
  <ul>
     {% Dim errIter 
        For errIter = 1 To CurrentQuestion.Errors.Count
     %}
        <li>{%= CurrentQuestion.Errors[errITer].Message %}</li>
     {% Next %}
  </ul>
</li></ul>
{% EndIf %}

Produces:

<ul class="question-errors"><li>Ranking
   <ul>
      <li>Rank 2 is missing for question `Ranking`</li>
      <li>Rank 3 has been given more than once for question `Ranking`</li>
   </ul>
</li></ul>

↑ Top of page ↑

HasAnswered

Available from version 5.4.6.3

Indicates whether the question's already an answer (was already asked).

Returns a Boolean.

Example
gender.HasAnswered ' => True

↑ Top of page ↑

HasDK

Indicates whether the question's answer is "don't know" (DK).

Returns a Boolean.

Example
gender.HasDK ' => False

↑ Top of page ↑

HasNA

Indicates whether the question has a "not asked" answer.

Returns a Boolean.

Example
gender.HasNA ' => False

↑ Top of page ↑

HasNoData

Available from version 5.3.5.

Indicates whether there is some data in the question (i.e. whether the question was skipped or not).

Returns a Boolean.

Example
gender.HasNoData ' => False

↑ Top of page ↑

HasParentChapter

Available from version 5.4.1.

Indicates whether the question has an ancestry chapter. This property searches upwards in the questionnaire hierarchy until it reaches a parent chapter.

Returns a Boolean.

Questions
Q1.HasParentChapter ' => True
gender.HasParentChapter '=> False

↑ Top of page ↑

HasParentLoop

Available from version 5.3.3.

Indicates whether the question is inside a loop.

Returns a Boolean.

Examples
Q1.HasParentLoop ' => True
gender.HasParentLoop '=> False

↑ Top of page ↑

HasValidData

Available from version 5.3.5.

Indicates whether the question's answer is valid. Applies to open, numeric and closed questions only. This method checks whether a value is present and if so, whether that value is compatible with:

Returns a Boolean.

Example
gender.HasValidData ' => True

↑ Top of page ↑

Id

Available from version 5.3.3.

Internal unique identifier of the question.

Returns a Number.

Example
gender.id  ' => 1
age.id ' => 2

↑ Top of page ↑

ImportClosed

Available from version 5.6.1.

Indicates how the closed question are used for the importation for this question.
0 --> When the question is not a closed question
1 --> Using modality caption
2 --> Using modality order
3 --> Using modality entry code

Returns a Number.

Examples

gender.ImportClosed' => 1 (for Using modality caption)

profession.ImportClosed' => 3 (for Using modality entry code)

↑ Top of page ↑

ImportInvisibleWhenImported

Available from version 5.6.1.

Indicates that the question is invisible if a data is imported for this question.

Returns a Boolean.

Examples

gender.ImportInvisibleWhenImported' => True

profession.ImportInvisibleWhenImported' => False

↑ Top of page ↑

ImportType

Available from version 5.6.1.

Indicates the type of importation for this question.
0 --> None
1 --> Entry list (Deprecated)
2 --> ODBC query
3 --> Panel (sent by Cca)
4 --> GeoCATI Field
5 --> Internet parameter
6 --> Platform one
7 --> Fulcrum
8 --> All internet parameter as JSON

Returns a Number.

Examples

gender.ImportType ' => 5 (for Internet parameter)

profession.ImportType ' => 3 (for Panel)

↑ Top of page ↑

InputCode

Available from version 5.4.6.

Indicates the base code of the HTML input for this question.

Returns a Number.

See also: ADC Generate Askia HTML inputs

Examples
 ' Single
gender.InputCode ' => "0"
 ' Numeric
age.InputCode  ' => "1"
 ' Multiple
brands.InputCode ' => "2"
 ' Open
comment.InputCode ' => "3"
 ' Date only
birthday.InputCode ' => "4"
 ' Time only
meetingHour.InputCode ' => "5"

↑ Top of page ↑

Instructions

Available from version 6.5.0.

Returns the instructions of the question

Returns a String.

Examples
Q1.Instructions ' => Please enter some numbers

↑ Top of page ↑

IsAllowDK

Available from version 5.3.3.

Indicates whether the question allows a "don't know" answer.

Returns a Boolean.

Examples
gender.IsAllowDK ' => false
age.IsAllowDK ' => true

↑ Top of page ↑

IsAnonymised

Available from version 5.5.2.8

Indicates whether the question is anonymised.

Returns a Boolean.

Examples
gender.IsAnonymised ' => false
age.IsAnonymised ' => true

↑ Top of page ↑

IsDateOnly

Available from version 5.3.3.

Indicates whether the date question accepts a date only (i.e. without the time).

Returns a Boolean.

Examples
MyDateWithoutTime.IsDateOnly ' => true
MyDateWithTime.IsDateOnly ' => false

↑ Top of page ↑

IsFirstIteration

Available from version 5.6.1.

Available only for loops. Indicates if we are on the first iteration of a loop shown.

Returns a Boolean.

Example
Loop1.IsFirstIteration ' => True

↑ Top of page ↑

IsLastIteration

Available only for loops. Indicates if we are on the latest iteration of a loop.

Returns a Boolean.

Example
Loop1.IsLastIteration ' => True

↑ Top of page ↑

IsLiveRoutingSource

Available from version 5.4.5.

Indicates if the current question is a live routing source.

Returns a Boolean.

Example
Question.IsLiveRoutingSource  ' => True

↑ Top of page ↑

IsOrdered

Available from version 5.3.3.

Indicates whether a multi-coded question also records the order of response selections.

Returns a Boolean.

Examples
rankingBrands.IsOrdered ' => true
knowingBrands.IsOrdered ' => false

↑ Top of page ↑

IsSkipped

Available from version 5.5.0.

Returns true if the question is skipped.

Returns a Boolean.

Examples
 gender.IsSkipped ' => true

↑ Top of page ↑

IsTimeOnly

Available from version 5.3.3.

Indicates whether the date question accepts a time only (i.e. without the date).

Returns a Boolean.

Examples
MyTimeWithoutDate.IsTimeOnly ' => true
MyTimeWithDate.IsTimeOnly ' => false

↑ Top of page ↑

IsUppercase

Available from version 5.6.1.

Indicates if for the open ended question, Uppercase is ticked.

Returns a Boolean.

Examples
MyOpen.IsUppercase ' => true
MyOpen.IsUppercase ' => false

↑ Top of page ↑

LinkSourceQuestion

Available from version 5.6.1.

Return the Question object of the source link question.

Returns a Question.

Examples
MyQuestion.LinkSourceQuestion.Shortcut ' => MySourceQuestion

↑ Top of page ↑

LinkTopLevel

Available from version 5.6.1.

Indicates if Link to top level responses and make headers selectable is ticked.

Returns a Boolean.

Examples
MyQuestion.LinkTopLevel ' => true
MyQuestion.LinkTopLevel ' => false

↑ Top of page ↑

LinkType

Available from version 5.6.1.

Indicates the type of link used on the question.
0 --> None
1 --> All responses
2 --> All selected responses
3 --> All non selected responses
4 --> Selected responses in all linked questions

Returns a Number.

Examples
MyBrands.LinkType ' => 3 (for All non selected responses

↑ Top of page ↑

LongCaption

Returns the long caption of the question, in the current language.

Returns a String.

Example
gender.LongCaption ' => "Are you..."

↑ Top of page ↑

MaxDate

Available from version 5.3.3.

Indicates the maximum allowed value for a date question.

When no maximum has been specified, this method returns DK.

Returns a Date.

Examples
 ' Date question with maximum date "31/12/2013" 
MyDate.MaxDate  ' => #31/12/2013#
 ' Date question without maximum value
MyDate.MaxDate  ' => DK

↑ Top of page ↑

MaxValue

Available from version 5.3.3.

Indicates the question's maximum expected value, number of responses or length, depending on the question type:

When no maximum is expected, this method returns DK.

Returns a Number.

Examples
 ' Multi-coded question with maximum 5 responses
Brands.MaxValue  ' => 5
 ' Numeric question with 99 as maximum value
age.MaxValue  ' => 99
 ' Open-ended question with 5 maximum characters
postalCode.MaxValue ' => 5
 ' Question without maximum value
CurrentQuestion.MaxValue ' => DK

↑ Top of page ↑

 

MaxVisibleIterations

Available from version 5.5.2

Returns the MaxVisibleIterations properties set on a loop.

If you have 3 iterations on the loop and you set the MaxVisibleIterations to 2 then it will return the 2 first iterations on the first page then the last one on the second page.

Returns a Number (0 if All iterations set on the loop).

Example

MaxVisibleIterations set to 2
loop.MaxVisibleIterations ' => 2
MaxVisibleIterations set to All iterations
loop.MaxVisibleIterations ' => 0

↑ Top of page ↑

 

MinDate

Available from version 5.3.3.

Indicates the minimum allowed value for a date question.

When no minimum has been specified, this method returns DK.

Returns a Date.

Examples
 ' Date question with minimum date "01/01/2013" 
MyDate.MinDate  ' => #01/01/2013#
 ' Date question without minimum value
MyDate.MinDate  ' => DK

↑ Top of page ↑

MinValue

Available from version 5.3.3.

Indicates the question's minimum possible value, number of responses or response length, depending on the question type:

When no minimum is expected, this method returns DK.

Returns a Number.

Examples
 ' Multi-coded question with minimum 3 responses
Brands.MinValue  ' => 3
 ' Numeric question with 18 as minimum value
age.MinValue  ' => 18
 ' Open-ended question with 5 minimum characters
 ' This example is currently fictional because the
 ' system doesn't have a minimum length value
 ' for open-ended question
postalCode.MinValue ' => 5
 ' Question without minimum value
CurrentQuestion.MinValue ' => DK

↑ Top of page ↑

ParentChapter

Available from version 5.4.1.

Only available for questions that have an ancestry chapter. Returns the first ancestry parent chapter.

Returns a Question.

Example
Q1.ParentChapter ' => <Question::Chapter>

↑ Top of page ↑

ParentLoop

Only available for a question inside a loop. Returns the parent loop question.

Returns a Question.

Example
Q1.ParentLoop ' => <Question::Loop>

↑ Top of page ↑

ParentQuestion

Available from version 5.5.0.

Returns the parent question.

Returns a Question.

Examples
 gender.ParentQuestion

↑ Top of page ↑

Questions

Available from version 5.5.0.

Returns the list of all the child questions.

Returns a collection of Questions.

Examples
 gender.Questions

↑ Top of page ↑

Responses

Returns the entire list of responses for a closed question.

Returns a Collection of Responses.

Example
gender.Responses ' => {<Response::1#Man> ; <Response::2#Woman>}

↑ Top of page ↑

RotationSeed

Returns the content of the seed rotation applied to the question.
-2 --> Reused for question with same number of responses
-1 --> Different for every question
Any other positive number --> Defined by seed

Returns a number.

Example
gender.RotationSeed ' => -1 (for Different for every question)

↑ Top of page ↑

RotationType

Returns the type of rotation applied to the question.
0 --> Never
1 --> Randomise
2 --> Rotate
3 --> Invert
4 --> Alphabetical

Returns a number.

Example
gender.RotationType ' => 3 (for inverted)

↑ Top of page ↑

Scenarios

Returns the list of scenarios applied for a question.

Returns an array of string.

Example
gender.Scenarios ' => {"Client";"NonClient"}

↑ Top of page ↑

ShortCaption

Returns the short caption of the question, in the current language. If the ShortCaption is empty, then it returns the LongCaption.

Returns a String.

Example
gender.ShortCaption ' => "Respondent Gender"

↑ Top of page ↑

Shortcut

Returns the question shortcut (the name of the variable).

Returns a String.

Example
gender.Shortcut  ' => "gender"
^1. appreciation^.Shortcut   ' => "1. appreciation"

↑ Top of page ↑

Tags

Available from version 5.5.0.

Returns an Array of String.

Examples
 gender.Tags ' => {"tag1";"tag2"}
 gender.Tags.Count  ' => "2"
 gender.Tags[2] ' => "tag2"

↑ Top of page ↑

Type

Returns the question type as a string. The possible types are:

Returns a String.

Examples
gender.Type ' => "single"
brands.Type ' => "multiple"
age.Type ' => "numeric"
comment.Type ' => "open"
birth.Type ' => "datetime"
gridLoop.Type ' => "loop"
iterationSelectionLoop.Type ' => "single-loop"
preliminarySelectionLoop.Type ' => "multiple-loop"
numericSelectionLoop.Type ' => "numeric-loop"

↑ Top of page ↑

UserData

Available from version 5.5.3

Returns the data stored in the User Data field.

Returns a String.

Examples
gender.UserData ' => "some text"
CurrentQuestion.UserData ' => "some JSON"

↑ Top of page ↑

Value

Returns the value(s) (answers) of the question in the current iteration.

When there is no response, the value returned is DK, except in the case of open-ended and multi-coded questions:

Examples

gender.value ' => 1

age.value ' => 33
brands.value ' => {3; 5; 6}
q1_other.value ' => "bla bla bla"
birthday.value ' => #14/02/1978#

When no value is specified:

gender.value ' => DK
age.value ' => DK
brands.value ' => {}
q1_other.value ' => ""
birthday.value ' => DK

↑ Top of page ↑

Visibility

Available from version 5.6.1

Indicates the status of the visibility of the variable.
0 --> None
1 --> Only sub questions
2 --> Full

Returns a Number.

Examples
gender.Visibility ' => 2 (for Full)

↑ Top of page ↑

VisibleInDataEntry

Available from version 5.5.2

Indicates if the variable is visible during data entry.

Returns a Boolean.

Examples

gender.VisibleInDataEntry ' => True

age.VisibleInDataEntry ' => False

↑ Top of page ↑

Methods

ChangeSubQuestionsOrder(order)

Available from version 5.4.1.

Equivalent to the routing action  change order. Changes the order of any direct sub-questions and returns the question for the call chain. This method is available only when running R/W scripts not when evaluation conditions.

Returns a Question.

Parameter
Example
Dim randomOrder = {1; 2; 3}.Shuffle()
ChapterQuestionnaire.ChangeSubQuestionsOrder(randomOrder)

↑ Top of page ↑

EntryCodeToIndex(entryCodes)

Returns the index(es) (base 1) of the specify entry code(s).

Parameter
Examples
country.EntryCodeToIndex("US") ' => 1
country.EntryCodeToIndex({"US"; "DUMMY"; "UK"}) ' => {1; DK; 2}

↑ Top of page ↑

GotoURL()

Available from version 5.5.0.

return the URL to use to go to this question.

Returns a String.

Note: In order to use it for a nagivation, the URL used in a href should include at the end of the GoToUrl() link the shortcut of the question like this:

<a href='{%:= question.GotoURL() + "&shortcut=" + question.Shortcut %}'>your link</a>
Example
age.GotoURL()

↑ Top of page ↑

IndexToEntryCode(indexes)

Same as IndexToEntryCodeStr, but converts the return value(s) to number(s).

Parameters
Examples
brands.IndexToEntryCode(1) ' => "001" 
brands.IndexToEntryCode(1) ' => 1

↑ Top of page ↑

IndexToEntryCodeStr(indexes)

Returns the entry code(s) of the response(s) at the specified index(es).

Parameter
Examples
country.IndexToEntryCodeStr(1) ' => "US"
country.IndexToEntryCodeStr({1; -3; 2}) ' => {"US"; ""; "UK"}

↑ Top of page ↑

InputName([type])

Available from version 5.3.3.

Indicates the base name of the HTML input for this question.

Returns a String.

Parameter

See also: ADC Generate Askia HTML inputs.

Examples
 ' Single
gender.InputName() ' => "U0"
 ' Numeric
age.InputName()  ' => "C1"
 ' Multiple
brands.InputName() ' => "M2"
 ' Open
comment.InputName() ' => "S3"
 ' Date only
birthday.InputName() ' => "D4"
 ' Time only
meetingHour.InputName() ' => "T5"
 ' Date and time
departure.InputName("date") ' => "D5" 
departure.InputName("time") ' => "T5"
 ' Ranking question
brands.InputName("ranking") ' => "R2"
 ' List with multiselection
brands.InputName("list") ' => "L2"

↑ Top of page ↑

InputValue([type])

Available from version 5.3.3.

Returns the HTML-escaped version of the Question.Value, to prevent interpretation of the < and > characters and also for special unicode characters.

Returns a String.

Parameter

Also see: ADC Generate Askia HTML inputs

Examples
gender.InputValue() ' => "256"
brands.InputValue() ' => "256,257"
comment.InputValue() ' => "If < 200 and not > & that "work"" 
' Where comment.Value return: 
'  "if < 200 and not > & that "works""
age.InputValue() ' => "33"
birthday.InputValue() ' => "12/12/2012"
departure.InputValue("date") '=> "24/05/2012" 
departure.InputValue("time") '=> "12:05:00"

↑ Top of page ↑

Iteration(LoopIndex+)

Returns a question inside a loop, at a specific loop index.

Returns a Question object

Info : Available only for a question inside a loop.
Parameters

The number of parameters for this method is dynamic and is equal to the number of the parent loops:

We recommend that you specifically indicate the loop name using the following syntax:

Question.Iteration(LoopName1 : LoopIndex1, LoopName2 : LoopIndex2)

In this case, the order of the parameters doesn't matter, and the previous syntax is equivalent to this 

Question.Iteration(LoopName2 : LoopIndex2, LoopName1 : LoopIndex1)

Alternatively, this syntax also works :

Question.Iteration(LoopIndex1, LoopIndex2)

The first parameter refers to the immediate parent loop, the second parameter refer to the next loop above and so on. While less verbose, this syntax is more prone to scripting errors.

Examples
 ' Q1 is inside a loop named "loop" 
Q1.Iteration(1)  '=> Q1 in the first iteration
 ' Q1 is inside a loop named "loop" 
Q1.Iteration(loop : 2) ' => Q1 in the second iteration
 ' Q1 is inside a loop named "loop" 
Q1 '=> Q1 in the current iteration
 ' Q1 is inside two nested loop "subLoop" which is inside "topLoop" 
Q1.Iteration(1) ' => Q1 in the first iteration of the 'subLoop' loop 
                ' and in the current iteration of the 'topLoop' loop
 ' Q1 is inside two nested loop "subLoop" which is inside "topLoop" 
Q1.Iteration(1, 2)  ' => Q1 in the first iteration of the 'subLoop' loop 
                    ' and in the second iteration of the 'topLoop' loop
 ' Q1 is inside two nested loop "subLoop" which is inside "topLoop" 
Q1.Iteration(topLoop : 2) ' => Q1 in the second iteration of the 'topLoop' loop
                          ' and in the current iteration of the 'subLoop' loop
 ' Q1 is inside two nested loop "subLoop" which is inside "topLoop" 
Q1.Iteration(topLoop : 2, subLoop : 1) ' => Q1 in the second iteration of the 'topLoop' loop 
                                       ' and in the first iteration of the 'subLoop' loop
 
Execution flow example
Warning : This keyword behaves differently depending if the "Start question" after which the filter runs is in a loop or not.

Example : checking of the value of Q1 is > 0 during the 3rd iteration of LoopName

Case 1 : the filter is inside the current loop

When the filter is on the current loop flow, parameters are optional.

Q1.Iteration(LoopName1 : LoopName.CurrentIteration)

becomes equivalent to 

Q1

So, we can use

Q1.value > 0 AND LoopName.CurrentIteration = 3

 

Case 2 : the filter is outside the current loop

When the script is used outside the loop flow, all parameters are required.

Q1.Iteration(LoopName : 3) > 0

Info : All omitted parameters are, by default, initialised with the current loop iteration.

 

 

↑ Top of page ↑

OnlyAskSubQuestions(Questions)

Ask only the questions shortcuts present in the Questions parameters and in the same order they appear in the parameter. This is available only when running R/W scripts, not when evaluating conditions.

Parameters

Questions (string): The list of questions shortcut to ask separated by semi-colon ";"

Examples
 Chapter

   Q1

   Q2

   Q3

   Q4 
Chapter.OnlyAskSubQuestions(“Q3;Q1”) which would hide Q2 and Q4 and show Q3 and Q1 first

↑ Top of page ↑

SetValue(value)

Available from version 5.4.1.

Equivalent to the routing action set value.

Sets the specified value(s) in the specified question and returns the question for the call chain. This is available only when running R/W scripts, not when evaluating conditions.

Returns a Question.

Parameter
Examples
If age < 18  Then
   ageRecod.SetValue(1)
Else If age >= 18 And age < 26 Then
   ageRecod.SetValue(2)
Else If age >= 26 And age < 36 Then
   ageRecod.SetValue(3)
Else If age >= 36 And age < 50 Then
   ageRecod.SetValue(4)
Else
   ageRecod.SetValue(5)
EndIf
 ' Example with call chain
If brands has {1; 2} Then
   q2.SetValue({1; 2}).SkipAndKeepData()
EndIf

↑ Top of page ↑

Skip

Available from version 5.4.1.

Equivalent to the routing action do not ask.

Skips the question and does not keep its data. This is available only when running R/W scripts, not when evaluating conditions.

Returns a Question.

Example
If age < 18  Then
   AdultQuestions.Skip()
EndIf

↑ Top of page ↑

SkipAndKeepData()

Available from version 5.4.1.

Equivalent to the routing action make question invisible.

Skips the question and keeps its data, returning the question for the call chain. This method is available only when running R/W scripts, not when evaluation conditions.

Returns a Question.

Examples
If age < 18  Then
   AdultQuestions.SkipAndKeepData()
EndIf
' Example with call chain
If brands has {1; 2} Then
   q2.SkipAndKeepData().SetValue({1; 2})
EndIf

↑ Top of page ↑

ToString()

Returns a string which represents the question object (expressed in JSON format).

Returns a String.

Examples
 ' Output in a single line (it's break here for the readability)
gender.ToString()
' => {
"shortcut":"gender", 
"shortCaption":"Respondent gender", 
"longCaption":"Are you?", 
"type":"single" 
}
 ' Output in a single line (it's break here for the readability)
' q1 is in loop of loop
q1.ToString() 
' => {
"shortcut":"q1", 
"shortCaption":"Q1", 
"longCaption":"Q1", 
"type":"single",
"iterations":{"parentLoop":4,"subLoop":2}
}

↑ Top of page ↑

TypeOf()

Always returns "question".

Returns a String.

Example
gender.TypeOf() ' => "question"

↑ Top of page ↑

Operators

Operators for a question are equivalent to operators for a question value. For example:

Q1 has {1;2;3}
' Equivalent to
Q1.value has {1;2;3}
' Equivalent to
??Q1?? has {1;2;3}

The question value (or values) will be a number, string, date or array, according to the question type.

↑ Top of page ↑

Create your own Knowledge Base