SELECT function

Synopsis
This function returns an array after applying an expression to each element of a source array.
Variations
SELECT(SourceArray, Expression)
Returns all elements in the source array after performing an expression on each element.
Parameters
SourceArray

Specifies the array to select from.

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

Specifies the expression to apply to each element of the source array.

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

The following example selects the entire array and multiplies each element by 2. The function returns [10, 8, 6, 4, 2].

SELECT([5, 4, 3, 2, 1], Item*2)
2.

SELECT can be used to create an array of point objects from the results of steps, such as BlobAnalysis, ModelFinder, or BeadInspection, that generate objects with separate values for X and Y coordinates. The following example creates the array of point objects from ModelFinder occurrences.

SELECT(Flowcharts("MainFlowchart").ModelFinder.Occurrences, POINT(Item.X, Item.Y))
3.

The following example copies an array of points from the operator view display to an array of point objects.

SELECT(OperatorInputs.Inputs("inPts").Points, Item.PixelPoint)
SELECT(SourceArray, StartIndex, Count, Expression)
Returns all elements in a subset of the source array after performing an expression on each element.
Parameters
SourceArray

Specifies the array to select from.

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

Specifies the beginning of the subset of the source array.

Supported types: Numeric.
Count

Specifies the number of elements to include in the subset of the source array.

Supported types: Numeric.
Expression

Specifies the expression to apply to each element of the source array.

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

The following example selects only the first 3 elements of the array and multiplies each by 2. The function returns [10, 8, 6].

SELECT([5, 4, 3, 2, 1], 1, 3, Item*2)
2.

The following example returns an array where each element represents the difference between each element in the source array and the previous element in the source array. The array that is returned can be referred to as the difference array. Since the first element in the source array has no previous element, it is ignored when calculating the difference array (therefore the StartIndex parameter of the SELECT function is set to 2 instead of 1).

SELECT (Flowchart.MyArray, 2, ItemCount - 1, Item.Y - Flowchart.MyArray(Index - 1).Y)