Expressions: Frequently Used Functions
Below is a list of frequently used functions that you can use per data type. Since every application can have a different composition, some functions may not be available in your application (yet).
To find a complete list of all functions in your application, check the data model in the Expression Debugger.
For a fundamental explanation of our expression language and its syntax, you can take a look at Expressions in Novulo.
String functions
The following functions are assumed to be applied to a string we’ll call stringX
.
Function | Returns | Explanation | |
---|---|---|---|
. |
appendnewline() [1] |
string |
Adds a line break |
. |
concat(stringY) |
string |
Pastes stringY behind stringX |
. |
contains(stringY) |
boolean |
Checks if stringY appears in stringX (is slower than startswith(stringY) or equals(stringY) ) |
. |
endswith(stringY) |
boolean |
Checks if stringY appears at the end of stringX (is slower than startswith(stringY) or equals(stringY) ) |
. |
in([string]) |
boolean |
Checks if stringX appears in a list of strings |
. |
isinteger() [1:1] |
boolean |
Checks if stringX can be transformed to an integer |
. |
isnullorempty() [1:2] |
boolean |
Checks if a string is empty or equal to "" |
. |
length() [1:3] |
int |
Counts the characters in a string |
. |
replace(stringY,stringZ) [1:4] |
string |
Replaces all instances of stringY of stringX with stringZ |
. |
startswith(stringY) |
boolean |
Checks if stringY appears at the beginning of stringX |
. |
substring(intX,intY) [1:5] |
string |
Returns a subset of characters from stringX with length intY , starting at the intX position |
. |
tointeger() [1:6] |
int |
Transforms stringX into an integer |
. |
tolower() [1:7] |
string |
Replaces all capital letters in stringX with lowercase letters |
. |
toupper() [1:8] |
string |
Replaces all lowercase letters in stringX with capital letters |
The following examples can be used in the Expression Debugger. Try them out!
Examples
Function | Example |
---|---|
appendnewline() |
"Hello".appendnewline().appendnewline().concat("world!") |
concat(string) |
"Hello".concat(" world!") |
contains(string) |
"Hello world!".contains("hello") |
endswith(stringY) |
"Hello world!".endswith("world!") |
equals(stringY) |
"Hello world!".equals("hello world!") |
in([string]) |
"world".in(["Hello Novulo!","Hello world!"]) |
isinteger() |
"123".isinteger() |
isnull() |
"".isnull() |
isnullorempty() |
"".isnullorempty() |
length() |
"Hello world!".length() |
replace(stringY,stringZ) |
"Hello Novulo!".replace("Novulo!","world!") |
startswith(stringY) |
"Hello world!".startswith("hello") |
substring(intX,intY) |
"I prefer my examples to say Hello world!".substring(28,12) |
tointeger() |
"123".tointeger() |
tolower() |
"HELLO WORLD!".tolower() |
toupper() |
"hello world!".toupper() |
Generic functions
“Generic” of course isn’t a data type. However, some functions can be declared from all data types. These are summarized here.
Function | Returns | Explanation | |
---|---|---|---|
. |
equals(value) |
boolean |
Checks if stringY is the same as stringX |
: |
if(booleanX,then,else) |
Any | Evaluates booleanX : if true , returns the expression in then , if false , returns the expression in else . The else and then expressions must result in the same data type that has been declared |
. |
isnull() |
boolean |
Checks if a string is empty (not recommended, use isnullorempty() instead) |
List functions
Similarly to the generic functions, these functions are not technically “list” functions. They are all declared from some data type and return another data type, but these all have a list as a parameter. Because of their usefulness, I grouped them together here.
In stead of describing the result of the functions, I’ll specify which data types they can be declared from. For instance: int:count(list)
counts integers, but can also be applied as money:count(list)
, persons:count(list)
, etc.
Remember that a list expression comes in the form {DataType, Expression, Filter, Sorting}
, or as [Expression1, Expression2, ...etc.]
as described here.
Data_type | Function | Explanation | |
---|---|---|---|
Any[2] | : |
count(list) |
Counts the values in the list |
Any[2:1] | : |
exists(list) |
Checks if the list has at least one value |
Any[2:2] | : |
first(list) |
Returns the first value in the list |
Any[2:3] | : |
itemat(list,intX) |
Returns the intX -th value in the list |
Any[2:4] | . |
in([list]) |
Checks if the value appears in the list |
int , float , money , percentage |
: |
min(list) |
Returns the lowest value in the list |
int , float , money , percentage |
: |
max(list) |
Returns the highest value in the list |
string |
: |
join(stringX,list) |
Pastes all values of the list behind eachother, separated by stringX |
int , float , money , percentage |
: |
sum(list) |
Sums the values in the list |
Requires the String Extensions plugin ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎
The result of the
Expression
of the list must be the same as the declared data type. Soint:count({persons,age()})
,string:count({persons,first_name})
andpersons:count({persons,this})
are all valid expressions, whileint:count({persons,this})
is not ↩︎ ↩︎ ↩︎ ↩︎ ↩︎