|
Expression Syntax
|
Top Previous Next |
| 1. | + or - unary operator (e.g. numeric prefix like +5, -10)
|
| 2. | NOT, !
|
| 3. | ^
|
| 4. | *, /, %
|
| 5. | +, -
|
| 6. | >=, <=
|
| 7. | =, !=, <>, >, <
|
| 8. | AND
|
| 9. OR
|
| · | Function names are not case-sensitive (Today = TODAY)
|
|
|
| · | Function names must be immediately followed by the '(' character, with no space after the function name.
|
|
|
| · | There is no distinction between integer or floating-point numeric values. Internally they are all treated as floating-point, though some functions will only use the integer (truncated) portion.
|
|
|
| · | Parenthesis may be used around expressions to force the operator precedence.
|
|
|
| · | Anything not recognized as an operator, value or a function call is assumed to be a Variable, e.g. in 2 * R * Pi(), "R" is assumed to be a variable.
|
|
|
| · | Spaces are not required around operators, values, or variables, but they are allowed (and recommended for readability).
|
|
|
| · | Text can be enclosed in single or double quotes ( " or ' ). These can be nested inside each other to one level, if a function call requires a quoted expression (for instance, the following are OK: Evalq( "Evalq( 'Str(5)' )" ) or Evalq( "Str(5) + ' this is a 5.' " ), but this is not: Evalq( "Evalq( "Str(5)" )" )
|
|
|
| · | If a quote is needed inside a text string, it can be escaped with a backslash: "He said \"Hi\" to me".
|
|
|
| · | All expression elements have a result "type", e.g. numeric or text, and the result type is determined by the expression's final result. For instance, 2+2 is numeric, 2>2 is boolean, "2+2" is text. Some types cannot be mixed, e.g. 2 + "2" is not valid, but numbers and dates can be added or subtracted: {1/1/05} + 30 will add 30 days to the date 1/1/05.
|
|
|
| · | Any part of an expression not enclosed in quotes is parsed and evaluated, even if the result is not used. For instance in the expression iif( 2>3, 2+2, 2+4 ), all 3 expressions inside the iif() function are parsed an evaluated, even though the 2+2 expression is ultimately ignored. This is especially important when using functions which do things, like SetFieldValue(). You may not want it to "evaluate" all of them. This is where functions like iifq() come in handy, since the quoted expressions passed to it are just considered text except for the one that's used as the return value.
|
|
|
| · | There is no limit to the length of an expression or the levels of nesting, e.g. within function calls or parenthesis.
|
|
|
| · | There is a shorthand that can be used for some data field values, if used on the "Operational" record. For instance: Resv:Resv_Type is equivalent to FieldText( ThisResv(), "Resv_Type"). The shorthand versions are parsed slightly slower but are executed much faster. The Expression Elements dialog or Select Fields dialog will insert the shorthand version automatically when possible.
|
| · | Variables can be of any type. Once the variable is created, its type is set also (to the type of the expression used in the SetVar function).
|
|
|
| · | Variable names must start with a letter and may contain letters or digits. They are not case-sensitive.
|
|
|
| · | Global variables will retain their value system-wide, but can be overridden by a local variable created with the same name.
|
|
|
| · | Local variables are short-lived, generally only for the current expression or expressions evaluated therein.
|
|
|
| · | Any local variable that exists before a sub-expression is parsed and executed, such as in functions like CallScript, Macro, IIFQ, EvalQ, etc., is copied into the sub-expression and available therein, and its value is also copied back out.
|
|
|
| · | Any local variable that does not exist before a sub-expression is parsed and executed but is created within the sub-expression will be destroyed before sub-expression returns.
|
|
|
| · | These rules apply for any depth level of sub-expressions.
|
|
|
| Expressions Overview
|
| Expression Context
|
| Expression Processing
|
|
|
| Expression Creator Dialog
|
| Expression Elements
|
|
|
| Function Reference
|
|
|
| Advanced Customizations Overview & other topics
|
|
|