Literals
A literal is a value that you write directly in EFX, such as 'Lot 1', 42 or 2024-03-01Z. Each data type has
its own form of literal, so the form of a literal shows its data type: you write texts in quotes, and all the other
literals without quotes. A list of literals in square brackets, a sequence literal, gives the value of a sequence
parameter.
Text literal
A text literal is a value of type text.
'<characters>'
"<characters>"
{<uuid>}
- <characters>
-
zero or more Unicode characters, on a single line. A backslash starts an escape sequence (see below).
- <uuid>
-
a UUID in its usual form of 32 hexadecimal digits in five groups,
8-4-4-4-12, separated by hyphens.
You write a text literal in single quotes or in double quotes. The two forms mean the same. You can write a single
quote inside double quotes, and a double quote inside single quotes: "it's", 'say "yes"'. The empty text is
'' or "".
A backslash followed by the enclosing quote stands for that quote: 'it\'s' is the same text as "it's". A
backslash followed by any other character stays as written, together with that character: '\d' is the two
characters \ and d. In this way, the escape sequences of regular expressions, which you write as text
literals, reach the regular expression unchanged (see
Regular expressions). A text literal has no escape
sequence for a line break or a tab.
You can also write a text literal as a UUID in braces, without quotes, for example
{d290f1ee-6c54-4b01-90e6-d701748f0851}. Its value is a text.
Restrictions
-
A backslash cannot be the last character before the closing quote, because
\'(or\") does not close the literal.
Examples
WITH ND-Root COMPUTE BT-00-Text == 'Lot 1'
WITH ND-Root COMPUTE 'it\'s' == "it's"
Two ways of writing the same text.
WITH ND-Root COMPUTE concat('Total: ', text(BT-00-Number))
WITH ND-Root COMPUTE BT-00-Text like '[0-9]+\.[0-9]{2}'
In a regular expression, \. stays as written and matches a full stop.
| In EFX-1, a text literal could not contain the other kind of quote without a backslash, and only some characters could follow a backslash. In EFX-2, either quote can appear inside the other, and any character can follow a backslash. |
Number literal
A number literal is a value of type number.
<digits> <digits>.<digits> .<digits> -<number-literal>
- <digits>
-
one or more decimal digits.
- <number-literal>
-
a number literal without a sign.
You write a number in decimal notation, with a full stop as decimal separator: 42, 12.5, 0.25, .5. You can
write leading zeros. A minus sign makes the number negative, and you can put spaces between the sign and the digits.
EFX does not distinguish between whole and decimal numbers.
The minus sign belongs to the literal, so you cannot put it before anything else: -BT-00-Number and
-(BT-00-Number + 1) are errors. To change the sign of a field value, write 0 - BT-00-Number or
BT-00-Number * -1.
Restrictions
-
There is no exponent notation (
1e3) and no grouping separator (1,000). A comma is never a decimal separator. -
At least one digit must follow a decimal point:
1.is an error.
Examples
WITH ND-Root COMPUTE BT-00-Number > 1000
WITH ND-Root COMPUTE BT-00-Number * 0.25
WITH ND-Root COMPUTE BT-00-Number <= 9999.99
A decimal number with several digits before the decimal point.
WITH ND-Root COMPUTE BT-00-Number * -1
A negative literal.
| In EFX-1, the minus sign had to come directly before the digits. In EFX-2, you can put spaces between them. |
See also: Number, Arithmetic operators
Indicator literal
An indicator literal is one of the two values of type indicator.
TRUE FALSE ALWAYS NEVER
TRUE and ALWAYS both stand for true, and FALSE and NEVER both stand for false. Use ALWAYS and NEVER for a
condition that never changes, for example to say that a field is always mandatory.
You write indicator literals in upper case only: true or True is not an indicator literal.
Examples
WITH ND-Root COMPUTE BT-00-Indicator == TRUE
WITH ND-Root COMPUTE if BT-00-Number > 0 then BT-00-Indicator else NEVER
fields/fields.json)WITH ND-Root COMPUTE TRUE
The default value of the assert property of the field BT-01-notice.
See also: Indicator, Case sensitivity
Date literal
A date literal is a value of type date.
<year>-<month>-<day>Z <year>-<month>-<day>+<hours>:<minutes> <year>-<month>-<day>-<hours>:<minutes>
- <year>
-
four digits.
- <month>, <day>
-
two digits each.
- <hours>, <minutes>
-
two digits each: the offset of the time zone from UTC.
You write a date literal without quotes. It always ends with a time zone: an upper-case Z for UTC, or a positive or
negative offset from UTC with a colon, such as +01:00. The time zone is required, because eForms requires a
time zone for all dates.
Restrictions
-
You cannot leave out the time zone. Without it, the text is not a date:
2024-01-01is read as the subtraction2024 - 01 - 01, which is the number 2022. -
A date literal has no quotes:
'2024-01-01Z'is a text.
Examples
WITH ND-Root COMPUTE BT-00-StartDate >= 2024-01-01Z
WITH ND-Root COMPUTE BT-00-EndDate < 2024-12-31+01:00
WITH ND-Root COMPUTE BT-00-StartDate - 2024-01-01Z > P30D
The difference between a date field and a date literal is a duration.
Time literal
A time literal is a value of type time.
<hours>:<minutes>:<seconds>Z <hours>:<minutes>:<seconds>+<zone-hours>:<zone-minutes> <hours>:<minutes>:<seconds>-<zone-hours>:<zone-minutes>
- <hours>, <minutes>, <seconds>
-
two digits each.
- <zone-hours>, <zone-minutes>
-
two digits each: the offset of the time zone from UTC.
You write a time literal without quotes, with hours, minutes and seconds. Like a date literal, it always ends with a time zone.
Restrictions
-
You cannot leave out the seconds or the time zone:
09:00Zand09:00:00are errors. -
A time literal has no fractions of a second:
09:00:00.5Zis an error.
Examples
WITH ND-Root COMPUTE BT-00-StartTime >= 09:00:00Z
WITH ND-Root COMPUTE BT-00-EndTime <= 17:30:00+01:00
Duration literal
A duration literal is a value of type duration.
P<number>D P<number>W P<number>M P<number>Y -P<number>D -P<number>W -P<number>M -P<number>Y
- <number>
-
one or more decimal digits: a whole number.
You write a duration literal without quotes: P (for period), a whole number, and a unit: D for days, W for
weeks, M for months or Y for years. A week is seven days. A minus sign in front makes the duration negative, which
you can use in calculations.
Durations in days or weeks and durations in months or years are two different kinds of duration, because months and years do not all have the same length (see Duration).
Restrictions
-
A duration literal has a single unit:
P1Y6Mis an error. WriteP18M. -
A duration literal cannot be in hours, minutes or seconds:
PT12His an error. -
The number is a whole number:
P1.5Yis an error. -
You write
Pand the unit in upper case.
Examples
WITH ND-Root COMPUTE BT-00-Duration <= P6M
WITH ND-Root COMPUTE add-duration(BT-00-StartDate, P2W) < BT-00-EndDate
WITH ND-Root COMPUTE add-duration(BT-00-EndDate, -P1Y) > BT-00-StartDate
A negative duration: the end date minus one year.
Sequence literal
A sequence literal is a list of literals of one data type, which gives a sequence.
[<literal>, <literal>, …]
- <literal>
-
a literal of one of the forms above. All the literals of a sequence literal have the same data type.
Sequence literals are the values of sequence parameters, such as text*:$codes (see
Parameters of a single expression).
The application that uses the expression gives them, for example ['works', 'services'] or
[2025-01-01Z, 2025-12-25Z].
Inside an expression, the same notation is a sequence construction, whose items can be any expressions, not only
literals: [1, 2, 3], [BT-00-Number, 0] (see
Sequence construction).
Restrictions
-
A sequence literal contains at least one literal:
[]is an error. -
All its literals have the same data type:
['works', 1]is an error.
Examples
WITH ND-Root, text*:$codes COMPUTE BT-00-Code in $codes
With the sequence literal ['works', 'services'] as the value of $codes.
WITH ND-Root, number*:$allowed COMPUTE BT-00-Number in $allowed
With the sequence literal [1, 2.5, -3] as the value of $allowed.
WITH ND-Root, date*:$holidays COMPUTE BT-00-StartDate not in $holidays
With the sequence literal [2025-01-01Z, 2025-12-25Z] as the value of $holidays.
EFX-1 had no sequence parameters, and wrote lists of values in parentheses: ('a', 'b').
|
See also: Sequence