C# Language Basics: learn the foundations of the language we use to write expressions for controlling the questionnaire logic.
Survey Solutions uses C# language for writing the expressions, such as enabling or validation conditions. Yet, where we thought the language features may be misused to create vulnerabilities, we’ve restricted its use by disallowing certain C# data types, such as accessing files or network. If you are getting a “Forbidden type” error (corresponding error codes are WB0272, WB0273, WB0274, WB0275) the expression you’ve written is probably following the correct syntax, but is not going to compile for the reason of security.July 20, 2021
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.November 21, 2016
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 16, 2016
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 = 10August 15, 2016
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 10, 2016
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. Links are provided to the corresponding definitions on Microsoft’s site.August 9, 2016