Desktop User Guides > Professional > Interview scripting > Writing interview scripts > Multiple-language scripts > Showing example input formats
 
Showing example input formats
There are various ways of entering numbers and dates in interviews, all of which depend to some extent on the interview’s language or locale. One of the most common problems relates to the decimal point: is it a comma or is it a dot? If the interview language is one that requires a comma as the decimal point, then any decimal responses that are entered with a dot will be rejected. Similarly, if the language is one that requires a dot as the decimal point, numbers that contain a comma will be rejected. The error message that the user sees depends on the browser language, the script language and locale, and the character entered as the decimal point, but it will usually state either that the response is not numeric or that the thousands separator is not allowed.
You can help respondents and interviewers avoid these problems by displaying an example of the required response format as part of the question. There are several ways of doing this.
Numbers with .Ask()
To mark the point at which the example response should be displayed, place an insert marker inside the question text. (For more information about inserts, see Programmatically inserting text into labels.)
{<example>[:<format>]}
where
<example> is the name of the insert marker.
:<format> specifies how the value should be formatted. For more information, see Formatting substituted values.
For example:
WeeklyFood "How much do you spend on food in an average week? (e.g.
  {spend:f})"
Then, type the Ask() statement as follows:
<name>.Ask(<value>)
where:
<name> is the question name.
<value> is a number.
When the question is displayed during interviews, the insert marker in the question text is replaced with this value, formatted according to the given format string and the interview language. Here are some examples produced by:
WeeklyFood.Ask(1234,5)
Insert
Produces
{spend:f}
1234.50 (English) or 1234,50 (Continental European)
{spend:f3}
1234.500 (English) or 1234,500 (Continental European)
{spend:n}
1,234.50 (English), 1 234,50 (French), or 1.234,50 (German)
{spend}
1234.5
There is no requirement for the value to be within the valid response range for the question, although it is helpful to respondents if it is.
Dates with .Ask()
To mark the point at which the example date should be displayed, place an insert marker of the following form inside the question text:
{<example>[:<format>]}
Then, in the routing section, type:
<name>.Ask(CDate("<yyyy>-<mm>-<dd>"))
where:
<name> is the question name.
<yyyy>-<mm>-<dd> is the date.
When the question is displayed during interviews, the example date displays in the format required by the interview language. For example, if the question is
Expiry "When does your privilege card expire? (e.g.
  {exdate})" date;
and the routing section contains:
Expiry.Ask(CDate("2023-12-31"))
the date displays as follows:
Language
Date displayed as
British English, Western European languages, and equivalents
31/12/2023
US English and equivalents
12/31/2023
Eastern European languages and equivalents
2023–12–31 (the separator character varies between countries)
Numbers or dates with Format()
The other way of specifying example values for both numbers and dates is to use the standard syntax for defining insert values together with the Format function
<name>.Label.Inserts["<example>"].Text = Format(<value>, "<format>", , IOM.Locale)
where:
<name> is the question name.
<example> is the name of the insert marker in the question’s metadata.
<value> is a number enclosed in double quotation marks or a CDate expression defining the value for <example>.
<format> is a formatting code the specifies how <value> should be displayed.
For example, the previous examples could be written as:
WeeklyFood.Label.Inserts["spend"].Text = Format("12345","f2",,IOM.Locale)
Expiry.Label.Inserts["exdate"].Text = Format(CDate("2007-12-31"),"d",,IOM.Locale)
See also
Multiple-language scripts