Professional > Interview scripting > Writing interview scripts > Dealing with errors > Replacing the standard message texts
 
Replacing the standard message texts
You can define your own error messages to replace the standard texts for all questions or for individual questions. Defining message texts is very similar to defining questions and responses.
For all questions
To define replacement texts for the whole script, include the following in the metadata section:
StandardTexts block fields
(
  Errors block fields
  (
MessageName1 "Text 1" info;
    MessageName2 "Text 2" info;
    ...
  );
);
Parameters
MessageName
The name of the standard message you are replacing. See Standard error messages.
Text
The replacement message text.
You can define any number of replacement messages just by listing them one after the other inside the Errors block.
Replacement message texts can contain substitution markers for things such as question names or category texts, in the same way that markers are used in the standard texts. Substitution markers are always enclosed in curly braces to differentiate them from the message text, and are as follows:
Marker
Description
ANSWER
The respondent’s answer.
RANGE
The valid answer range for the question as defined in the metadata section.
QUESTION
The question name.
QUESTION_NUMBER
The question number.
LENGTH
The length of the response text.
MINLENGTH
The minimum length for a text response.
MAXLENGTH
The maximum length for a text response.
MINANSWERS
The minimum number of answers that must be chosen from a multiple choice list.
MAXANSWERS
The maximum number of answers that may be chosen from a multiple choice list.
CATEGORY
The text of a single multiple choice response.
ERROR
The error message associated with an internal error.
The substitution markers in the table apply to specific standard error messages only and replacements that you define for those messages. A replacement text can include some or all of the substitution markers that are used in the corresponding standard error message, but should not contain substitution markers that are used in other error texts. For example, the TooLittleText error is “The answer does not have enough text, current length is '{LENGTH}', minimum is '{MINLENGTH}'." Your replacement text may use both markers or neither of them. The replacement message “Incorrect text length. Must be between {MINLENGTH} and {MAXLENGTH} characters.” will not work because {MAXLENGTH} is not valid with TooLittleText. The interviewing program will treat the marker as ordinary text.
The same rule applies to other substitution markers (also known as inserts) that you might use elsewhere in the questionnaire script. These markers are not valid in error messages and will be treated as ordinary text.
Example
StandardTexts "StandardTexts" block fields
(
Errors "Errors" block fields
(
MissingAnswer "You have forgotten to answer the question."
info;
InvalidText "Your response is not in the right format."
info;
TooFewAnswers "You have not chosen enough answers. At least
            {MINANSWERS} are required."
info;
);
);
For individual questions
If you want to use a different message for just one question in a script, you define it in the metadata section as a helper text related to that question. Write the question’s definition as normal and then insert the helperfields block at the end of the definition:
Qname "Text" Definition
  helperfields
  (
    StandardTexts block fields
    (
      Errors block fields
      (
MessageName "MessageText" info;
  );
);
Parameters
Qname
The question name.
Text
The question text.
Definition
The remainder of the usual question definition, including the question type, length, and so on.
MessageName
The name of the standard message you are replacing: see Standard error messages.
MessageText
The replacement message text.
Example
The following message will be displayed only if the respondents enters an invalid response at the MembershipNumber question:
MembershipNumber "Please enter your membership number."
text [9..9]
helperfields (
StandardTexts "StandardTexts" block fields
(
Errors "Errors" block fields
(
InvalidText "Invalid number. Membership number format is UUnnnnnnU;
for example, AA123456Z." info;
);
);
) validation("\u{2}\d{6}\u{1}");
Note You can also use the StandardTexts block for defining your own texts for navigation buttons and for the special response texts No answer, Don't know, and Refused.
See also
Dealing with errors