Is there any way to make a sum of Numeric arrays in TestStand?

Updated Mar 28, 2024

Reported In

Software

  • TestStand

Issue Details

I would like to know how to make a sum of arrays in TestStand (similarly as done in LabVIEW) such as the resulting array contains the sum of each element with its corresponding member index.

I tried a statement using a for loop but the sum is not successful:
 

Locals.sum = {}, SetNumElements (Locals.sum, GetNumElements (Locals.array1))
for Locals.i = 0 to GetNumElements (Locals.array1) - 1
  Locals.sum [Locals.i] = Locals.array1 [Locals.i] + Locals.array2 [Locals.i]
end

 

Solution

You should be able to use a For Each loop for this.
  1. Create local variables for the numeric array to hold the result, a numeric to hold the current element and another numeric to hold the loop index (also called offset in TestStand)

  2. Resize numeric array to the corresponding size of the arrays to sum up using an expression Statement

  3. Create a For Each step with "Array to Iterate Over" set to the previously created numeric array, set "Current Element" to the create current element variable and set "Current Offset" to the created variable for the loop index

  4. Place an expression Statement inside the For Each loop with

    Locals.currentElement = Locals.array1[Locals.currentOffset] + Locals.array2[Locals.currentOffset]

     

Here is an example variable & sequence:
螢幕擷取畫面 2024-03-25 111739.png

enter image description here