Actions

Translations

Translations:ExpressionScript How-tos/13/en

From LimeSurvey Manual

Revision as of 16:50, 19 May 2020 by FuzzyBot (talk | contribs) (Importing a new version from external source)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here are examples of common errors when typing ES expressions. Note that the tooltips provide additional information.

  1. 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
  2. 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.
  3. 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.
  4. 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
  5. 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.
  6. Unsuported syntax
    • If you use an operator or punctuation that ES does not support, it will red-box it.
  7. 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