Built-in functions
This page describes the built-in functions of the Flow Connect platform. Note that additional functions are available in the built-in modules (described in subsequent chapters of this document).
Text-related functions
isNumber
Signature: isNumber(input: primitive) -> boolean
Returns a boolean value indicating whether the input argument can be converted into a number by the val function.
upper
Signature: upper(self input: text) -> text
Returns an uppercase version of the input argument.
lower
Signature: lower(self input: text) -> text
Returns an lowercase version of the input argument.
val
Signature: val(input: text) -> number
Converts the input argument to a number if possible. If the input cannot be meaningfully converted to a number, the function raises a runtime error. To preempt such errors, you can use the isNumber function.
The val function will interpret either point or comma as a decimal separator.
len
Signature: len(self input: text) -> number
Returns the number of characters in the input argument.
urlEncode
Signature: urlEncode(self input: text) -> text
Returns the input argument in URL Encoding.
urlDecode
Signature: urlDecode(self input: text) -> text
Converts the input argument from URL Encoding into regular text.
chr
Signature: chr(input: primitive) -> text
Converts a unicode code point (in decimal format) to the corresponding text value. Inputs must be in the Basic Multilingual Plane of Unicode, otherwise the function will raise an error.
left
Signature: left(self input: text, count: number) -> text
Returns a specified number of characters taken from the input text, starting from the left. If the number of characters specified by the count
argument exceeds the number of characters in the input, the whole of input will be returned. If count
is zero or less then an empty text will be returned.
right
Signature: right(self input: text, count: number) -> text
Returns a specified number of characters taken from the input text, starting from the right. If the number of characters specified by the count
argument exceeds the number of characters in the input, the whole of input will be returned. If the count
is zero or less then an empty text will be returned.
mid
Signature: mid(self input: text, index: number, count: number) -> text
Returns a specified number of characters taken from the input text, starting at the position indicated by the index
argument.
If the numbers of the characters specified by the count
argument exceeds the remaining characters after the index, the rest of the text will be returned.
The function will throw an error if the given start index is greater than or equal to the number of characters in the input.
regexMatch
Signature: regexMatch(input: text, pattern: text) -> boolean
Returns a boolean value indicating whether if the given Regular Expression pattern can be match in the input text.
regexMatches
Signature: regexMatches(input: text, pattern: text) -> text*
Returns a sequence of matches, if any, for the Regular Expression pattern in the input text.
regexReplace
Signature: regexReplace(self input: text, pattern: text, replacement: text ) -> text
Replaces the matches of the given Regular Expression pattern with the replacement argument in the input text. If nothing in the input matches the pattern, the original input will be returned.
replace
Signature: replace(self input: text, search: text, replacement: text ) -> text
Returns a value in which all occurrences of search
in input
are replaced with replacement
.
trim
Signature: trim(self input: text) -> text
Returns the input text with trailing and leading whitespace removed.
inStr
Signature: inStr(self source: text, lookFor: text) -> number
Returns the index of the first occurrence of the lookFor
argument in the source
text. If no occurrence exists inside the source
text, the function returns -1.
guid
Signature: guid() -> text
Creates a non-empty UUID as described in RFC 4122, Sec. 4.4.
str
Signature: str(input: any) -> text
Returns a text representation of the input. Null values will be converted to a empty text value.
rgb
Signature: rgb(red: number, green: number, blue: number) -> text
Returns the hex code corresponding the RGB color with given values of red
, green
and blue
. The arguments will be rounded to the nearest integer in the range of 0 through 255.
split
Signature: split(self input: text, delimiter: text ) -> text*
Returns all sub strings of the input argument, separated by the specified delimiter.
If the given delimiter is not present in the input text then a sequence consisting only of the input text will be returned.
The delimiter argument must be exactly one character long.
splitToTable
Signature: splitToTable(self input: text, delimiter: text ) -> {value: text}*
A version of the split function designed for compatiblity with Flow Classic.
join
Signature: join(self sequence: primitive*, separator: text ) -> text
Concatenates all the text values in the sequence
argument and returns a single text, inserting the separator
between each element.
format
Signature: format(input: primitive, pattern: text) -> text
Returns a formatted text representation of a given number or datetime input using the given pattern
to format it.
For numbers
Valid pattern
argument for numbers are the same as standard format specifiers provided by .NET to format numbers for decimal values.
For dates
Valid pattern
argument for numbers are the same as standard format specifiers provided by .NET to format dates.
formatLocale
Signature: formatLocale(input: primitive, pattern: text, locale: text) -> text
Returns a formatted text representation of a given number or datetime input using the given pattern and locale to format it.
The locale
argument corresponds to a langue code as described in BCP 47. If the locale argument is the empty text, the formatLocale function works the same as the format function.
For numbers
Valid pattern argument for numbers are the same as standard format specifiers provided by .NET to format numbers.
For dates
Valid pattern argument for numbers are the same as standard format specifiers provided by .NET to format dates.
Binary-related functions
encodeText
Signature: encodeText(self input: text, encoding: text) -> binary
Encodes the input text to binary value with the given encoding. Valid values for the encoding
parameter are: iso-8859-1
, utf-8
, utf-16
and utf-32
.
decodeText
Signature: decodeText(self data: binary, encoding: text) -> binary
Converts a binary value into a text representation using the provided encoding. Valid values for the encoding
parameter are: iso-8859-1
, utf-8
, utf-16
and utf-32
.
base64Encode
Signature: base64Encode(self data: binary) -> text
Converts a binary value into its Base 64 text representation.
base64Decode
Signature: base64Decode(self base64: text) -> binary
Converts a base64 encoded text into a binary file.
Null-related functions
isNull
Signature: isNull<T>(value: T?, replacement: T) -> T
Returns value
if is not null, otherwise returns the replacement
argument.
isNullOrEmpty
Signature: isNullOrEmpty(value: text?, replacement: text) -> text
Returns value
if it is not equal to null or the empty string (""); otherwise returns the replacement
argument.
Number-related functions
ceil
Signature: ceil(input: number) -> number
Rounds input
argument upward to the nearest integer.
floor
Signature: floor(input: number) -> number
Rounds input
downward to the nearest integer.
random
Signature: random(min: number, max:number) -> number
Generates a pseudo-random number between min
and max
.
max
Signature: max(a: number, b:number) -> number
Returns the greatest of a
and b
.
min
Signature: min(a: number, b:number) -> number
Returns the least or a
and b
.
pow
Signature: pow(base: number, exponent: number) -> number
Returns the base
raised to the exponent
.
round
Signature: round(x: number) -> number
Returns x
rounded to the nearest integer.
sum
Signature: sum(sequence: number?*) -> number
Returns the sum of the numbers in a sequence. Returns 0 if the sequence is empty. Null values count as zero.
Date-related functions
See also the DateTime module.
now
Signature: now() -> datetime
Returns a datetime value containing the calendar date and time indicated by the system clock of device on which the FlowScript is running.
date
Signature: date(input: text) -> datetime
Converts the input argument to a datetime if possible. If the input cannot be converted to a date, the function raises an error.
The date function supports several different date and time formats such as YYYY-MM-DD, ISO 8601 and more.
toDate
Signature: toDate(input: text, format: text) -> datetime
Converts the input argument to a datetime with the given format if possible. if the input cannot be converted to a date using the specified format, the function raises an error.
Sequence-related functions
See also the Seq module.
any
Signature: any(self sequence: unknown*) -> boolean
Returns a boolean value indicating whether the sequence has at least one element.
count
Signature: count(self sequence: unknown*) -> number
Returns the number of items in a sequence.
first
Signature: first<T>(self sequence: T*) -> T
Returns the first element from the sequence, or raises an error if the sequence is empty.
firstOrDefault
Signature: firstOrDefault<T>(self sequence: T*, defaultValue: T) -> T
Returns the first element from the sequence. If the seauence is empty, the function returns the defaultValue
argument.
firstOrNull
Signature: firstOrNull<T>(self sequence: T*) -> T?
Returns the first element from the sequence. If the seauence is empty, the function returns null.
last
Signature: last<T>(self sequence: T*) -> T
Returns the last element from the sequence, or raises an error if the sequence is empty.
lastOrDefault
Signature: lastOrDefault<T>(self sequence: T*, default: T ) -> T
Returns the last element from the sequence, or the default
argument if the sequence is empty.
lastOrNull
Signature: lastOrNull<T>(self sequence: T*, default: T ) -> T?
Returns the last element from the sequence, or null if the sequence is empty.
range
Signature: range(start: number, count: number) -> number*
Returns a sequence of count
integers beginning with start
.
take
Signature: take<T>(self sequence: T*, count: number ) -> T*
Returns the first N elements of the sequence.
skip
Signature: skip<T>(self sequence: T*, count: number ) -> T*
Returns a sequence where the first N elements are skipped.
eval
Signature: eval<T>(self sequence: T*) -> T*
Materializes a lazy sequence. See also A note on laziness.
flatten
Signature: flatten<T>(self sequence: T**) -> T*
Flattens a sequence-of-sequences into a single sequence.
empty
Signature: empty<T>(self sequence: T*) -> T*
Returns an empty sequence with the same type as the given argument. This function only exists for reasons of Flow Classic compatiblity.
Miscellaneous
hash
Signature: hash(value: any) -> number
Returns a numeric hash of the value.
identity
Signature: identity<T>(x: T) -> T
Returns the x
argument. If the type argument is explicitly written out, the function can be used to "upcast" values to the primitive type.
sleep
Signature: sleep(minMilliseconds: number, maxMilliseconds: number) -> number
Pauses script execution for a randomly chosen number of milliseconds between minMilliseconds
and maxMilliseconds
.
Last updated