Translations:ExpressionScript How-tos/13/en
From LimeSurvey Manual
Here are examples of common errors when typing ES expressions. Note that the tooltips provide additional information.
- Inline Javascript that forgot to add spaces after curly brace
- Since "document.write" appears right after a curly brace, EM thinks it is an expression, and red-boxes "document" and "write" since they are undefined variable and functions, respectively
- Unknown/Misspelled variables, functions and operators
- Here we forgot that we are using the variable name "gender" instead of "sex", but EM catches that error. It also red-boxes '++', since that is not a supported operator.
- Warns if use = instead of eq, or perform value assignments
- Note that the '=' and '+=' are in red text instead of black. If you hover the mouse over them, you will see warnings that you are assigning a value.
- Wrong number of arguments for functions
- if() takes 3 arguments, but it has been given 4, so hovering over the red-boxed "if" will explain the error and show the supported syntax
- sum() takes an unlimited number of arguments, but we had a trailing comma before the closing parentheses, so that is red-boxed
- Mismatched parentheses
- This is one of the most common errors when writing expressions.
- This shows two examples of missing closing parentheses, and one example of having one too many closing parentheses.
- Unsuported syntax
- If you use an operator or punctuation that ES does not support, it will red-box it.
- Invalid assignments
- Some variables are readWrite and can have their values changed. Others are read-only.
- If you try to change the value of a read-only variable, you can't. EM will red-box the attempt.
- If you try to assign a value to an equation or a string, you will also get an error