Expressions
Template allows you to use expression language to define variables and operations on them. This way you can derive new values and reduce necessary input either from user or external system.
Elements
123
- Number"Peter"
- Constant stringName
- Variable+
- OperatorABS(X)
- Function
Numbers
Numbers and operations with them are handled with highest precision. Acceptable number format is simple: 123.456
- starting with digits, followed by decimal separator and ending with digits again. Decimal part is not mandatory.
Variables
Simple word defines a variable name. It consists from upper or lower case letters and can contain, but cannot start with underscore character. Valid names could look like:
Name
email
UnitPrice
order_number
You can define or refer variable within an object. We are using so called dot notation, where .
character connects object and variable name. Following expression defines Address object with City property:
Address.City
Operators
+
- addition-
- subtraction*
- multiplication/
- division%
- modulo>
- greater than>=
- greater than or equal to<
- lower than<=
- lower than or equal to=
- assignment==
- equal!=
or<>
- not equal
Functions
NOT(A)
- logical negationAND(A, B, ...)
- logical ANDOR(A, B, ...)
- logical ORIF(C, A, B)
- if logical condition C is true, result is A, otherwise BABS(A)
- absolute value of number AMAX(A, B, ...)
- maximum value of values A, B, ...MIN(A, B, ...)
- minimum value of values A, B, ...SIZE(V)
- size of vector VSUM(V, X)
- sum of expression X on vector VSUMC(V, X, F, T)
- conditional sum of expression X on vector V, where expression F has target value TNUM(N, D)
- print number N with D digits, pad with leading zeroesNUM(N, D, P)
- print number N with D digits and P decimal places, pad with leading and trailing zeroesROUND(D, S)
- round decimal number D with S scale, rounding half upREPLACE(A, B, C)
- replace string B with string C in A expressionDATE(D, F)
- print date D in F format (y, M, d, H, m, s)TO_DATE(A, F)
- parse string A to date using format F (y, M, d, H, m, s)DAYS(D)
- convert number of days D to date
Types
Variable can be of types: boolean, number, string, date and vector. Default type is string, but other types are calculated based on operations or functions used on them. For example, if you use expression A + 3
, type of A
will be set to number. It then eliminates input errors, because user is forced to enter a number.
In cases when expressions A + 3
and A + ".pdf"
are used, conflicting type of A
as number and string will be resolved as setting type to more format strict one, which is a number in this case.
Was this article helpful?
Yes
No