FLATTEN function

Synopsis
This function extracts a sub-array of items from an array of objects so that they can be operated on.
Variations
FLATTEN(SourceArray, SubArray)
Returns an array containing all sub-array items.
Parameters
SourceArray

Specifies the array to select.

Supported types: Numeric array; String array; Boolean array; Point array; Object array.
SubArray

Specifies an array from each element of the source array.

Supported types: Numeric array; String array; Boolean array; Point array; Object array.
Returns
Returned types: Numeric array; String array; Boolean array; Point array; Object array.
Examples
1.

The following example extracts an object sub-array, itself an array within the ModelFinder.Models array. For each model defined in the ModelFinder step, the Item.Occurrences expression accesses an object array of model occurrences, with properties and statistics that can be referenced. The function returns a sub-array whose elements point to each model occurrence found.

FLATTEN(ModelFinder.Models, Item.Occurrences)
FLATTEN(SourceArray, SubArray, Expression)
Returns an array containing the result of the expression performed on all sub-array items.
Parameters
SourceArray

Specifies the array to select.

Supported types: Numeric array; String array; Boolean array; Point array; Object array.
SubArray

Specifies an array from each element of the source array.

Supported types: Numeric array; String array; Boolean array; Point array; Object array.
Expression

Specifies the expression to perform on the elements of the sub-array.

Supported types: Numeric; String; Boolean; Point; Object.
Returns
Returned types: Numeric array; String array; Boolean array; Point array; Object array.
Examples
1.

The following example extracts an array of StringsRead objects from their parent, the StringReader.StringModels object array. Each string read is considered an element of the StringsRead object sub-array. So, the TOUPPER() function accesses each string stored in the StringsRead sub-array and converts it to uppercase. The FLATTEN() function finishes execution by returning an array of the extracted, uppercase strings.

FLATTEN(StringReader.StringModels, Item.StringsRead, TOUPPER(SubItem.String))