Built-in functions
Built-in functions are the functions that come with EFX: they convert, test, compute and format values. You call them
by name, with their arguments in parentheses, for example count(BT-13-Text) (see
Built-in function call).
This page groups the functions by category, explains how their entries are laid out, and lists them in alphabetical
order. For the functions that you declare yourself, in template files, see
User-defined function call.
Categories
The categories group the built-in functions by the kind of value that they give or work on. When a function would fit several categories, its entry is in one of them, and the others mention it.
| Category | Functions |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
You can use the functions of the last category in template files only. You can use all the other functions everywhere: in single expressions, in template files and in rules files.
You write many tests and calculations with operators rather than functions, for example is present, in, like,
+ and == (see Operators). For the patterns that
like and replace-regex use, see
Regular expressions.
How entries are presented
Each function has one entry. The anchor of the entry is fn- followed by the name of the function. An entry gives:
-
the purpose of the function;
-
its syntax and its parameters;
-
a description of what it does;
-
its restrictions;
-
examples;
-
the differences from EFX-1;
-
related entries.
The syntax shows each form of the function on its own line, as a signature, that is, the name of the function, its parameters and the type of its result:
substring(<text>, <start>) → text substring(<text>, <start>, <length>) → text
The placeholders in angle brackets stand for the arguments, and the type after the arrow is the type of the result.
The list below the syntax gives the type and the meaning of each argument, and says which arguments are optional.
The types are the EFX data types: text, number, indicator, date, time and duration (see
Data types). A star marks a sequence: text* is a sequence
of texts.
Some functions, such as sort, accept a sequence of any data type. Their syntax calls the argument <sequence> and
the result sequence, which means a sequence of the same type as the argument. When a function has several forms for
different types, such as text, the translator chooses the form from the types of the arguments.
The following rules apply to all built-in functions:
-
You write function names in lower case.
COUNTandCountare not names of functions. -
An argument can be any expression of the required type: a literal, a field reference, a variable, a call to another function or a calculation. An argument of the wrong type is an error, which the translator reports when it translates the expression (see Type checking).
-
A parameter described as a single value (scalar) cannot receive a sequence. In particular, a field that can have several values from the context, such as a repeatable field, is an error there. Each entry says which parameters take a sequence.
-
A parameter that takes a sequence also accepts a single value, as a sequence of one value.
-
Several entries describe what happens when an argument "has no value", for example a field that is not present in the notice. Each entry gives the result in that case.
-
Some errors depend on the data, so EFX can find them only when the expression is applied to a notice. An example is a text that is not a valid date, given to
date. The entries name these errors.
Unless an entry says otherwise, its examples are expressions read from the root of the notice, ND-Root. The examples
of template-only functions are complete template lines.
A note labelled "EFX-1" says whether the function is new in EFX-2 or has changed. A function without such a note works as in EFX-1.
Alphabetical list
| Function | Purpose |
|---|---|
Absolute value of a number. |
|
Adds a duration to a date. |
|
Arithmetic mean of a sequence of numbers. |
|
Converts the first character of a text to upper case. |
|
Joins texts into one text. |
|
Tests whether a text contains another text. |
|
Number of values in a sequence. |
|
Number of values in a sequence that repeat an earlier value. |
|
The current date. |
|
The current time. |
|
Converts a text to a date. |
|
Day of the month of a date. |
|
Converts a text to a duration in days, hours, minutes and seconds. |
|
Number of whole days in a duration. |
|
The values of a sequence without duplicates. |
|
Tests whether a text has no characters. |
|
Tests whether a text ends with another text. |
|
Formats a date or a time in a long form (templates only). |
|
Formats a date or a time in a medium form (templates only). |
|
Formats a number following a picture (templates only). |
|
Formats a date or a time in a short form (templates only). |
|
The values that occur more than once in a sequence. |
|
Hours of a time. |
|
Position of a value in a sequence. |
|
Position of a text inside another text. |
|
Converts a number to an indicator. |
|
Converts a text to lower case. |
|
Largest number of a sequence. |
|
Smallest number of a sequence. |
|
Minutes of a time. |
|
Month of a date. |
|
Total number of months in a duration. |
|
Removes the white space at the start and end of a text, and reduces each run of white space inside it to one space. |
|
Negates an indicator. |
|
Converts a text or an indicator to a number. |
|
Adds characters at the start of a text up to a given length. |
|
Adds characters at the end of a text up to a given length. |
|
Language of the best-suited value of a multilingual text field (templates only). |
|
Best-suited value of a multilingual text field (templates only). |
|
Repeats a text a given number of times. |
|
Replaces every occurrence of a text by another text. |
|
Replaces every part of a text that matches a regular expression. |
|
The values of a sequence in reverse order. |
|
Rounds a number to the nearest whole number. |
|
Rounds a number down to a whole number. |
|
Rounds a number up to a whole number. |
|
Seconds of a time. |
|
Tests whether two sequences contain the same values, in any order. |
|
The values of a sequence in ascending order. |
|
Splits a text into a sequence of texts. |
|
Tests whether a text begins with another text. |
|
|
Another name for text. |
Joins the texts of a sequence, with a separator. |
|
Number of characters in a text. |
|
Part of a sequence. |
|
Part of a text. |
|
Part of a text after a delimiter. |
|
Part of a text before a delimiter. |
|
Subtracts a duration from a date. |
|
Total of a sequence of numbers. |
|
Converts a number, an indicator, a date, a time or a duration to text. |
|
Converts a text to a time. |
|
Removes the white space at the start and end of a text. |
|
Removes the white space at the start of a text. |
|
Removes the white space at the end of a text. |
|
Converts a text to upper case. |
|
Encodes a text for use in a web address. |
|
The values of a sequence that do not occur in another. |
|
The values that occur in both of two sequences. |
|
The values that occur in either of two sequences. |
|
Year of a date. |
|
Converts a text to a duration in years and months. |
|
Number of whole years in a duration. |