Expression
Overview
Informat adopts expressions using UEL (Unified Expression Language) syntax, which is similar to JavaScript expressions in syntax and semantics.
Features
- No type conversion required; conversions are usually done implicitly
- Double quotes and single quotes have the same usage
object.propertyhas the same meaning asobject['property']- Parts outside
${}are returned as strings
Here is a simple example of the Unified Expression Language:
Object
let person = {
name: 'Zhang San',
age: 18
}Type Returns
Expressions can directly declare and return variables
String Concatenation
Expressions in Informat are divided into two cases: executed on the client side and executed on the server side. When executed on the client side, + can be used in expressions to concatenate strings with any objects into new strings. For example:
Note
When executed on the server side, + string concatenation is not supported
${'123'+'456'} //Returns '579'If you need to perform string concatenation, you need to use String.concat(s1,s2)
${String.concat('123','456')} //Returns '123456'Operators
INFO
- Arithmetic: + (addition), - (subtraction), * (multiplication), / (division), % (modulus)
- Logical: && (and), || (or), ! (not)
- Relational: == (equal), != (not equal), < (less than), > (greater than) <= (less than or equal), >= (greater than or equal)
- Null: null
- Conditional: A ? B : C. Returns B or C, returns B if A is true, otherwise returns C
Reserved Keywords
Reserved keywords cannot be used as variable names
Reserved Keywords
and or not true false null empty div mod in matches eq ne lt gt le ge class
Division by Zero Exception
In division operations, if the divisor is 0, an exception will be thrown
Operation Examples
| Expression | Result |
|---|---|
| 1 > (4/2) | false |
| 4.0 >= 3 | true |
| 100.0 == 100 | true |
| (10*10) ne 100 | false |
| 4 > 3 | true |
| 1 + 2 > 2 - 1 | true |
| 1 < 2 && 2 > 1 | true |
| 1 < 2 | false |
| 2 > 1 | true |
| 'a' < 'b' | true |
| 1 + 2 | 3 |
| 1.2E4 + 1.4 | 12001.4 |
| 3 / 4 | 0.75 |
| 10 % 4 | 2 |
Function Call
Informat provides objects such as Math, Array, Date, Misc, String, User, Encode, Record to handle function operations related to mathematics, arrays, dates, etc. If an exception occurs during function call, the system will roll back the current transaction. Here is an example of a function call:
${Math.abs(-100)}//Returns 100
