Programmatically Inserting Elements, Rows, Columns, and Pages into Arrays

You can insert an element, row, column, or page into an array programmatically. What you can insert depends on how many dimensions the array has. For example, you can insert a row or a column into an array of two or more dimensions, but you cannot insert an element. You can insert a page into an array of three or more dimensions, but you cannot insert an element, row, or column.

Complete the following steps to insert elements, rows, columns, or pages in an array.

  1. Add an Insert Into Array function to the block diagram.

     Add  Find
  2. Wire an array of any dimension to the n-dim array input of the Insert Into Array function. The function automatically resizes based on the dimensions of the array.
  3. Determine which operation you want to perform from the following table and complete the associated steps.
Note  The index input specifies the element, row, column, or page where you want to insert the element or array, with 0 being the first. Elements and arrays are added before the value you wire to index. In the following table, n is the total number of elements, rows, columns, pages, or dimensions in the array.

Array wired to n-dimension array Inserting Complete these steps.
1D array Element Wire a value 0 through n to index.
Wire a value to new element/subarray.
1D array to row or column Wire a value 0 through n to index.
Wire a 1D array to new element/subarray.
2D array Row Wire a value 0 through n to index (row).
Wire a 1D array to new element/subarray.
Column Wire a value 0 through n to index (column).
Wire a 1D array to new element/subarray.
2D array (rows and columns) Wire a value 0 through n to index (row) or index (column).
Wire a 2D array to new element/sub array.
3D through nD array Page Wire a value 0 through n to index (page).
Wire a 2D array to new element/sub array.
3D array (pages) Wire a value 0 through n to index (page).
Wire a 3D array to new element/sub array.
  1. Resize the Insert Into Array function to insert another element(s), row(s), column(s), or page(s) in an array and repeat steps 2 and 3.
  2. Run the VI.

If the dimension size of the array you insert is smaller than the dimension size of the array you wired to the n-dim array input of the Insert Into Array function, the function pads the array you insert with default data, such as zeros in the case of an array of numeric values.

If the dimension size of the array you insert is larger than the dimension size of the array you wired to the n-dim array input of the Insert Into Array function, the function crops the array from the end.