Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ArgumentTypeDescription
setArray or Recordset

The Array array or Recordset recordset to get the result from.

indexInteger

The position of the item in

set to be returned.
default valueany type

Specify a default value to return instead of the item itself.

PhixFlow also returns this value:

  • ask for a position not in the array or recordset beyond the list you get Null or default
  •  instead of -NULL if the requested element does not exist.

If not specified

...

the array to be returned.

If index is not a valid entry, the function

...

returns:

  • either _NULL

...

  • or the specified default_value.

An invalid index is outside the array

...

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

...

or recordset. Index positions start at 1, so 0 is an invalid index. 

default_valueany type

Optionally, a default value to return instead of _NULL if the index is not valid.

If there is only one item in the set, getElement treats it 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 _NULL, as there is no element at position 8.


["Red", "Green", "Blue"].8

OR you will get the default value provided

...

Returns either _NULL or the default-value, because there is no eleme

getElement ([1,2,3],4)
getElement ([1,2,3],0)

...


[].1

Returns _NULL.


in.CustomerNames

...