Syntax Guide: Text questions

November 28, 2016

Responses to text questions are recorded as a string data type. The content for these types of questions consists of characters (e.g. the letter “A”), group of characters (e.g. “Mat”), or class of characters (e.g. white or empty space).
 
The following functions can be used in conditions for text questions:

  • Length: Checks the number of characters
  • “A text”: Checks that the response is exactly equal to a specified text (“A text”)
  • Contains: Checks that the response includes a specified text
  • ConsistsOf: Checks that the response includes one or more of the specified characters
  • IsAlphaLatin: Checks that the response consists of latin characters
  • IsAlphaLatinOrDelimiter: Checks that the response consists of latin characters and delimiters
  • IsNullOrWhiteSpace: Checks that the response is null or consists of blank spaces

 

Length 

Description

Checks the number of characters.
 

Syntax

varText.Length

This function checks the number of characters recorded.
 

Example 1

Suppose, you are recording the head of household’s name in a text question, and you know that in this particular context the full name should be more than 10 characters long. Therefore, the validation condition for this check would be:
 

hhead_name.Length>10

 

“A text”

Description

Checks that the response is exactly equal to a specified text (“A text”)
 

Syntax

varText== “A text”

This function checks that the response recorded matches the defined text (**“**A text”).
 

Example 1

To check that the response recorded in question “brandName” is Nike, the validation condition would be: 

brandName=="Nike"

Contains

 

Description

Checks that the response includes a specified text.
 

Syntax

varText.Contains(“aText”)

This function checks that the response includes a specified sub-text (“aText”).
 

Example 1

To check that the present participle verb recorded in the text question “actionWord”  includes “ing” , the validation condition would be: 

actionWord.Contains("ing")

 
 

ConsistsOf

Description

Checks that the response includes one or more of the specified characters.
 

Syntax 

varText.ConsistsOf(“aText”)

This function checks that the response includes one or more of the specified characters (“aText”).
 

Example 1

Assume you are recording the home address of the interviewee (address), and you want to make sure that it only includes letters, numbers, delimiters, and spaces.
 
The validation condition for this check would be:
 

address.ConsistsOf("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890., ")

 

IsAlphaLatin

Description

Checks that the response consists of alpha latin characters

Syntax

varText.IsAlphaLatin()

This function checks that the text in VarText consists of latin characters.
 

Example 1

Suppose, you are recording the first name of  the respondent for Module A (firstname). The response for this question must only consists of latin characters.

Therefore, the validation condition for this check would be:

self.IsAlphaLatin()

Or alternatively use the question’s variable name:

firstname.IsAlphaLatin()

 

IsAlphaLatinOrDelimiter

Description

Checks that the response consists of alpha latin characters and delimiters.
 

Syntax

varText.IsAlphaLatinOrDelimiter()

This function checks that the text in varText consists of latin characters and delimiters.
 

Example 1

Suppose, you have a questions asking for the head of household’s full name(hheadFullName), starting with the surname followed by a comma, and then the first name. For this check the validation condition would be:
 

self.IsAlphaLatinOrDelimiter()

Or alternatively use the question’s variable name:
 

hheadFullName.IsAlphaLatinOrDelimiter()

 

IsNullOrWhiteSpace

Description

Checks that the response is null or consists of blank spaces
 

Syntax

String.IsNullOrWhiteSpace(varText)

This function checks that the string(text) in the question varText consists of blank spaces or is null.
 

Example 1

Assume you are recording the first name of the respondent for Module A (firstname). The response for this question must not include spaces or be null.
 
For this check the validation condition would be:

!( String.IsNullOrWhiteSpace(self) )

 
or alternatively use the variable name:

!(String.IsNullOrWhiteSpace(firstname))