Array Operations Block

The Array Operations block does operations on the Numeric Array and Logic Array data types. You can create an array, add elements, read and write individual elements, and get the length of an array.

See Data Types for more information on arrays and other data types.
Choose the Operation


Mode Selector
Inputs
Output

Use the Mode Selector to choose the array operation and the array type (Numeric or Logic). The Inputs and Outputs available will change depending on the mode.
Modes
Append


The Append mode adds an element to the end of an array. You can also create a new array.

The Array In input specifies an existing array, and the Value specifies the element to add to the end of the array. If you leave Array In blank, a new array will be created with just the new element in it.
Tips and Tricks
You can create a new array with multiple elements in it by entering an array directly into the Array In input. See Data Types for information on how to enter an array directly into a block input.
The Array Out output will be a new array containing the combined elements. The original input array is not affected.

This table shows some examples of the Append – Numeric mode.
Array InValue to AddArray Out
3[3]
[1; 2; 3]4[1; 2; 3; 4]
[2; 1; 1; 6]1[2; 1; 1; 6; 1]
Read at Index


The Read at Index mode gets the value of an individual element in an array. The Array In input is the array to use. The element to get is specified by the Index. The first element in an array has an Index of 0, the second element has an Index of 1, and so on. The value of the selected element is output in Value.
Tips and Tricks
The Index of the last element in an array with n elements is n-1.
This table shows some examples of the Read at Index – Numeric mode.
Array InIndexValue
[1; 2; 3]01
[1; 2; 3]23
Write at Index


The Write at Index mode changes the value of an individual element in an array. The Array In input is the original array. The element to change is specified by the Index. The first element in an array has an Index of 0, the second element has an Index of 1, and so on.

The value to change the selected element to is specified by the Value. A new array with the element changed is output in Array Out. The original array in Array In is not affected.

This table shows some examples of the Write at Index – Numeric mode.
Array InIndexValueArray Out
[1; 2; 3]05[5; 2; 3]
[1; 2; 3]20[1; 2; 0]
Length


The Length mode gets the length of an array. The length of the array in the Array In input is output in Length.

The length of an array is the number of elements in the array. An empty array has a length of 0, and an array with a single element has a length of 1.
Inputs and Outputs
The inputs available for the Array Operations block will depend on the mode selected. You can enter the input values directly into the block. Alternatively, the input values can be supplied by Data Wires from the outputs of other Programming Blocks.
InputTypesNotes
Array In Numeric Array,
Logic Array
Array to operate on
Value Numeric,
Logic
Value to append in Append mode.

Value to change an element to in Write at Index mode.
Index NumericLocation of an array element to access.
0 = First element
1 = Second element
Length – 1 = Last element
The output available will depend on the mode selected. To use an output, use a Data Wire to connect it to another Programming Block.
OutputTypesNotes
Array Out Numeric Array,
Logic Array
Array result of the operation
Value Numeric, LogicValue of an array element in Read at Index mode
Length NumericLength of the array in Length mode
Array
Quick links