Learn how to use and combine different conversion functions in APL
Function Name | Description |
---|---|
dynamic_to_json | Converts a scalar value of type dynamic to a canonical string representation. |
ensure_field | Ensures the existence of a field and returns its value or a typed nil if it doesn’t exist. |
isbool | Returns a value of true or false if the expression value is passed. |
tobool | Converts input to boolean (signed 8-bit) representation. |
todatetime | Converts input to datetime scalar. |
todouble, toreal | Converts the input to a value of type real . todouble and toreal are synonyms. |
tohex | Converts input to a hexadecimal string. |
toint | Converts the input to an integer value (signed 64-bit) number representation. |
tolong | Converts input to long (signed 64-bit) number representation. |
tostring | Converts input to a string representation. |
totimespan | Converts input to timespan scalar. |
toarray | Converts input to array. |
todynamic | Converts input to dynamic. |
Ensures the existence of a field and returns its value or a typed nil if it doesn’t exist.
name | type | description |
---|---|---|
field_name | string | The name of the field to ensure exists. |
field_type | type | The type of the field. See scalar data types for supported types. |
This function returns the value of the specified field if it exists, otherwise it returns a typed nil.
In this example, the value of show_field
is nil because the myfield
field doesn’t exist.
In this example, the value of newstatus
is the value of status
because the status
field exists.
In this example, the query is prepared for a field named upcoming_field
that is expected to be added to the data soon. By using ensure_field()
, logic can be written around this future field, and the query will work when the field becomes available.
Converts input to boolean (signed 8-bit) representation.
false
Converts input to datetime scalar.
If the conversion is successful, the result will be a datetime value. Else, the result will be false.
Converts the input to a value of type real. (todouble() is an alternative word to toreal())
real.
If conversion is successful, the result is a value of type real. If conversion is not successful, the result returns false.
Converts input to a string representation.
Expr:
Expression that will be converted to string.If the Expression value is non-null, the result will be a string representation of the Expression. If the Expression value is null, the result will be an empty string.
Converts input to timespan scalar.
Expr:
Expression that will be converted to timespan.If conversion is successful, result will be a timespan value. Else, result will be false.
Converts input to a hexadecimal string.
If conversion is successful, result will be a string value. If conversion is not successful, result will be false.
Converts input to long (signed 64-bit) number representation.
If conversion is successful, result will be a long number. If conversion is not successful, result will be false.
Converts a scalar value of type dynamic
to a canonical string
representation.
Returns a canonical representation of the input as a value of type string
, according to the following rules:
If the input is a scalar value of type other than dynamic
, the output is the app of tostring()
to that value.
If the input in an array of values, the output is composed of the characters [, ,, and ] interspersed with the canonical representation described here of each array element.
If the input is a property bag, the output is composed of the characters {, ,, and } interspersed with the colon (:)-delimited name/value pairs of the properties. The pairs are sorted by the names, and the values are in the canonical representation described here of each array element.
Returns a value of true or false if the expression value is passed.
Returns true
if expression value is a bool, false
otherwise.
Converts the input to an integer value (signed 64-bit) number representation.
If the conversion is successful, the result will be an integer. Otherwise, the result will be null
.