...
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 Array array or Recordset recordset to get the result from. |
index | Integer | The position of the item in set tothe array to be returned. |
default value | any type | Specify a default value to return instead of the item itself. PhixFlow also returns this value:
If not specified |
If index is not a valid entry the function will return _NULL.
You expect get element to work on a list/array. Ask for something outside the array. Andy error but he got null... there is nothing at position 4
If you provided a default value
This default value is also used in the case where you ask for element 1 of an object that isn't a list. If you provide a default value then that is returned otherwise it just returns the object itself
If you dont; provide a list in get element, it doesnt fall over if you only ask for index 1
...
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 _NULL, the default_value "NoData" as there is no element at position 8. OR you will get the default value providedgetElement(5.
["Red"
...
Returns Red, treating it as if it is the first element in an array
getElement(["Red"], 2)
Returns either _NULL or the default-value, because there is no eleme
getElement ([1,2,3],4)
getElement ([1,2,3],0)
...
, "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".