...
Returns the item at a specified index position within an Array or Recordset.
Syntax
getElement(set, index)
getElement(set, index, default_value)
set[index]
set.index
Argument | Type | Description |
---|---|---|
set | Array or Recordset | The Arrayarray or Recordsetrecordset to get the result from. |
index | Integer | The position of the item in set tothe array to be returned. If index is not a valid entry |
...
, the function returns:
An invalid index is outside the array or recordset. Index positions start at 1, so 0 is an invalid index. | ||
default_value | any type | Optionally, a default value to return instead of _NULL if the index is not valid. |
If you use getElement on a single value, PhixFlow treats the value as the first item in an array.
Examples
getElement(["Red",
...
"Green",
...
"Blue"],
...
2)
Returns the 2nd element, "Green".
getElement(["Red"], 1)
Returns the element, "Red".
["Red",
...
"Green",
...
"Blue"].3
Returns the 3rd element, "Blue".
getElement(["Red", "Green", "Blue"], 5, "NoData")
Returns the default_value "NoData" as there is no element at position 5.
["Red",
...
"Green",
...
"Blue"].8
Returns _NULL, as there is:
- no element at position 8
- no default_value set.
[].1
Returns _NULL as there are no elements.
in.CustomerNames
returns a list of customer names that exist on the records on the in pipe. Please note that only recordsets can be indexed in this way, and lists must be accessed using numerical indices, as above.
in.$attributeName
will return the same as in.CustomerNames, if $attributeName is set to the string value $attributeName = "CustomerNames".