Text
The text type defines an open-ended question, which is a question that requires verbatim text as the response. The response data is stored using the Text data type, which contains a variable-length string that can in theory be up to approximately 2 billion characters in length. In reality, the length of a text response is limited by the database being used to store the response. Four thousand is the maximum number of characters that can be stored in a relational MR database, therefore, use 4000 as the maximum value when you write metadata script for use in UNICOM Intelligence Interviewer.
Syntax
For clarity, each item is shown on a separate line, and optional items are indented. See also
Syntax conventions.
field_name [ "field_label" ]
[ [ <properties> ] ]
[ <styles and templates> ]
text [ [ min_len .. max_len ] ]
[ <categories> ]
[ <codes> ]
[ validation ("validation_text") ]
[ expression ("expression_text") ]
[ ( initialanswer | defaultanswer ) (text) ]
[ <axis> ]
[ <usage-type> ]
[ <helperfields> ]
[ nocasedata ]
[ unversioned ]
Parameters
For
<axis>,
<usage-type>,
<helperfields>,
nocasedata, and
unversioned, see
Common parameters.
min_len..max_len
To specify
|
Syntax
|
No length restrictions
|
Field text;
|
|
Example:
Address1 text;
|
|
A verbatim response of any length is valid.
|
Maximum length
|
Field text [.. n1 ];
|
|
Example:
Name1 text [..30];
|
|
Any verbatim response of up to 30 characters is valid.
|
Minimum length
|
Field text [ n1 ..];
|
|
Example:
Name2 text [1..];
|
|
Any verbatim response of at least 1 character is valid.
|
Minimum and maximum length
|
Field text [ n1 .. n2 ];
|
|
Example:
Name3 text [1..30];
|
|
Any verbatim response of between 1 and 30 characters is valid.
|
Setting the length for the question to a maximum value of 40, or less, results in the text question being rendered with a single line edit box. Setting the maximum value to 41, or higher, results in the text question being rendered with a multiple line edit box.
<categories>
You can use the optional categories list to specify that the question will be presented as a single-response categorical question. If a category is selected, the value of the response will be the factor value assigned to that category by the factor keyword. Therefore, all categories should be assigned a factor value. In the following example, the value of Transport will be “T1”, “T2”, “T3” or “T4”, depending on which of the four categories is selected:
Transport "Which mode of transport do you use?" text
{
car "Car" factor("T1"),
bus "Bus" factor("T2"),
train "Train" factor("T3"),
cycle "Bicycle" factor("T4")
};
For further information about defining a category list, see
Categorical.
<codes>
The optional codes list is used to define special responses for the question. A code list is defined in the same way as a category list and is typically used to include Don't Know, No Answer, or Refused to Answer responses, which are identified by the DK, NA and REF keywords respectively. For example, the following text question called Movie has Don't Know and No Answer responses. Special responses are automatically marked as exclusive, meaning that they cannot be combined with any other answer. Only a text value, Don't know, or No answer are acceptable responses:
Movie "Your favorite movie?" text [0 .. 50] codes (
{
dontknow "Don't know" DK,
noanswer "No answer" NA
} );
When using the DK, REF or NA keywords, you can use a hyphen (-) as the category name to specify that the category name should be the same as the keyword.
A codes list can also be used to store the coded responses of open-ended questions. For example:
Improvements "How could brand X be improved?" text [0 .. 50] codes (
{
taste "Nicer taste",
packaging "Better packaging",
ingredients "More natural ingredients",
additives "Less additives"
} );
For information about defining a category list, see
Categorical.
validation
The validation option enables you to define the validation that is to be applied to open-ended responses.
You define the validation using regular expressions. For example, the following expression could be used to validate a telephone number consisting of four digits, a hyphen, and another four digits:
Phone text [9 .. 9] validation ("\d{4}-\d{4}");
expression
The optional expression keyword is used to create a variable using a formula defined in expression_text. Generally you use this feature to create a derived variable that is based on one or more other variables. For example, the following creates a variable that is based on the concatenation of the Name and Address text variables.
NameAddress "Name and address" text expression ("Name + "": "" + Address");
expression_text must be an expression that is supported by the UNICOM Intelligence Data Model and can optionally include functions from the
UNICOM Intelligence Function Library. Double quotation marks (") must be escaped using a second double quotation mark (for example,
"": "" in the previous example). Make sure that you check your syntax and spelling carefully, because the expression is stored without being validated. See
Expression evaluation for more information.
initialanswer and defaultanswer
You can optionally specify either an initial answer or a default answer to the question. An initial answer can be seen by the respondent, whereas a default answer can not be seen. If either type of answer is defined, the respondent does not need to answer the question. For example:
TravelToWork "If not by train, how do you get to work?" text [0 .. 20]
defaultanswer("train");
If a default answer is not accepted when you run the interview script, in other words, the message “Missing Answer(s)” is displayed, see
mrScriptMetadata FAQs.
Remarks
For more information about writing Text questions in interview scripts, see
Questions with text responses.
Example
The following defines a text question called FavoriteMoment with the question text What is your favorite scene from the movie? for which any text value up to a length of 100 characters or Don't Know are valid responses:
FavoriteMoment "What is your favorite scene from the movie?" text [0 .. 100]
codes (
{
- "I don't know" DK
} );
See