Function: getElement()
Returns the item at a specified index position within an Array or Recordset.
Syntax
- getElement(set, index)
- set[index]
- set.index
Argument | Type | Description |
---|---|---|
set | Array or Recordset | The Array or Recordset to get the result from. |
index | Integer | The position of the item in set 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 you provide not a list... index 1 returns the thing..... pretends it it is a list....pretends its a list of 1 object...
Examples
getElement(["Red", "Green", "Blue"], 2)
Returns the 2nd element, "Green".
["Red", "Green", "Blue"].3
Returns the 3rd element, "Blue".
["Red", "Green", "Blue"].8
Returns _NULL, as there is no element at position 8. OR you will get the default value provided
getElement(["Red"], 1)
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)
but currently just return null.
[].1
Returns _NULL.
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".