Syntax Guide

Data types

Survey Solutions uses C# language for enabling and validation conditions. C# is a contemporary general purpose object-oriented programming language, widely documented. When writing expressions in C# language, and especially when using standard C# and custom Survey Solutions functions it is important to keep in mind the definitions of the various Survey Solutions objects. Below the types of Survey Solutions objects are explained in terms of standard C# classes and types.

August 9, 2018

Dealing with exceptions

An exception is a situation where the computer can’t proceed with a normal flow of commands. A common example is a division by zero. The result of this operation is not defined. In statistics a concept of a missing value is introduced, and we normally don’t bother about the process. We know the result of X divided by zero ;will be a missing. In C# division by zero will cause the program to abort with an exception.

August 9, 2018

Syntax Guide: Operators

Designer has built-in operators that can be used in enabling conditions or validations. This article explains the following operators that you can use in your instrument: Arithmetic operators Relational operators Logical operators Other useful operators  Arithmetic Operators  The following table shows the arithmetic operators supported by Survey Solutions. Arithmetic expressions are evaluated from left to right. For the example, assume A = 20 and B = 10

August 9, 2018

Syntax Guide: System Generated Variables

These are variables that are created by Designer to allow the user to refer to certain variables or lines in a roster in enabling conditions or validation conditions. More detail is provided below about useful system variables: self, @rowcode, @optioncode, and @current. self For validation conditions, a very useful system generate variable isself. This variable denotes the value of the question being validated. Using self instead of the question’s variable name in a question’s validation conditions is advised because you will not have to change the variable name in the validation condition if the variable name for the question is changed.

August 9, 2018

Syntax Guide: Numeric Questions

Responses to numeric questions are recorded in the long data type for integer numbers and record in the double data type for real numbers (ie 1.5, 2.73, 15.25, 2.0). The following functions and operators can be used in conditions for numeric questions: Comparison to a value Relational Operators: less than, greater than, equal to, etc  Comparison to a range or several values   InRange: Checks if the number falls within a range InList: Checks if the number falls within a list of numbers  Math Functions These are the functions in the C# Math Class that could be useful in your instrument:

August 9, 2018

Syntax Guide: Single-select questions

Common tasks The section below lists the common tasks, and the elements of the syntax for accomplishing them. Comparison to a value Relational Operators less than, greater than, equal to, etc. Comparison to a range InRange. Checks if the selected answer falls within a range of user-specified values. Comparison to a list of values InList. Checks whether the selected answer is among the set of enumerated values.

August 9, 2018

Syntax Guide: Date questions

There are two types of date questions: Calendar and Current time. Both of these questions are recorded as DateTime? data type. Responses for the calendar data questions are recorded as {Year, Month, Day}. Meanwhile, responses to the current time questions are recorded as {Year, Month, Day, Hour, Minute, Second}. Calendar Comparisons Relational Operators. Less than, greater than, equal to, etc InRange. Checks if the date falls within an interval.

August 9, 2018

Syntax Guide: Using LINQ Expressions for Conditions in Rosters

Rosters are common survey instruments (ie household roster, assets roster, food consumption roster). Using Language Integrated Query (LINQ) and lambda expressions in the C# language, we are able to code enabling and validation conditions for rosters that can both: Horizontally: Refer to the values of other variables for the current occurrence Vertically: Refer to the values of the same variable for other items in the roster In this article, we will cover the general syntax, common operators, provide a few examples on how to write enabling and validation conditions for rosters.

August 9, 2018

Syntax Guide: GPS questions

Responses for the GPS questions are recorded as: class { double Latitude; double Longitude; double Accuracy; double Altitude; } The following functions can be used in conditions for GPS questions: Longitude, Latitude, Accuracy, and Altitude. Retrieves the latitude/longitude/accuracy/altitude of a GPS coordinate. InRectangle. *Check if the coordinates are inside a rectangle.*  GpsDistance. Calculate the distance between two coordinates in meters. GpsDistanceKm. Calculate the distance between two coordinates in kilometers.

August 9, 2018

Syntax Guide: Barcode questions

Responses for barcode questions are recorded as a string data type. The following functions can be used in conditions for barcode questions: Length: Checks the number of characters StartsWith: Checks that the barcode starts with specific characters EndsWith: Checks that the barcode ends with specific characters IsNumber: Checks that the barcode is a number ConsistsOf: Checks that the barcode consists of a specific set characters  Length Description Checks the number of characters.

August 9, 2018