Skip to content

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.property has the same meaning as object['property']
  • Parts outside ${} are returned as strings

Here is a simple example of the Unified Expression Language:

Object

javascript
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

javascript
${'123'+'456'} //Returns '579'

If you need to perform string concatenation, you need to use String.concat(s1,s2)

javascript
${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

ExpressionResult
1 > (4/2)false
4.0 >= 3true
100.0 == 100true
(10*10) ne 100false
4 > 3true
1 + 2 > 2 - 1true
1 < 2 && 2 > 1true
1 < 2false
2 > 1true
'a' < 'b'true
1 + 23
1.2E4 + 1.412001.4
3 / 40.75
10 % 42

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:

javascript
${Math.abs(-100)}//Returns 100