FIELDS Function

Returns one or more character-delimited fields from within each element of a dynamic array.

Syntax

FIELDS(dynArray, delimiter, fieldNumber{, numFields})

Syntax Elements

dynArray A DataBasic expression that evaluates to a dynamic array.

delimiter The character used as a field delimiter. If delimiter contains more than one character, only the first is used.

fieldNumber A positive integer specifying which field to return. The fields are numbered starting from 1. If the field number is less than 1, field 1 is returned.

numFields Optional. The number of fields, starting at fieldNumber, to return from each element (default, 1). If numFields is less than 1 or an empty string, the default is used.

Return Value

A dynamic array with the same structure as dynArray, but with each element replaced by the field(s) extracted from that element.

If delimiter is a empty string, an empty string is returned.

If fieldNumber is greater than the number of fields in the element concerned, that element is returned as an empty string (note that if delimiter cannot be found there is effectively just one field in the element).

If numFields is greater than 1, the extracted fields are separated by delimiter.

Case Insensitivity

If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching elements for delimiter.

See Also

FIELD function.

Example

ARY = "XXX:YYY:ZZZ:555":@AM:"AAA:BBB:CCC":@AM:"Paul:Jane:John:David"
NEWARY = FIELDS(ARY, ":", 3)

Sets NEWARY to "ZZZAMCCCAMJohn"