Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »



Function: getElement()

Returns the item at a specified index position within an Array or Recordset.

Syntax

  1. getElement(set, index)
  2. set[index]
  3. set.index
ArgumentTypeDescription
setArray or Recordset

The Array or Recordset to get the result from.

indexIntegerThe 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

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".

See Also

  • No labels