NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Array operations in TestStnand

I have a statement step in my sequence where I try and calculate the difference between two variables. The variables are defined as arrays (1 diminsion) with 8 elements. My expression looks like: Locals.z = Locals.x - Locals.y. I have checked to see that the x and y arrays are populated with data when I execute by using the watch expression pane, but I get the following error at my statement step and the z array never gets filled.

Details: The post-expression for the step 'Loop Delta' could not be evaluated.
Expected Number, found Array of Numbers.

Error Code: -17308; Specified value does not have the expected type.

Does anyone know what I am doing wrong?
0 Kudos
Message 1 of 3
(3,537 Views)
The "-" operator only applies to numeric values, not arrays.

You can loop and calculate the result for each index.

Init Expression: RunState.LoopIndex = 0
Increment Expr: RunState.LoopIndex += 1
Loop While Expr: RunState.LoopIndex < 8
Step Expression: Locals.z[RunState.LoopIndex] = Locals.x[RunState.LoopIndex] - Locals.y[RunState.LoopIndex]

This approach is fine for simple operations on relatively small arrays, but for large arrays or more complex operations, place this functionality in a language module (C, LabVIEW, etc.) that is better suited for performing mathematical operations.
0 Kudos
Message 2 of 3
(3,536 Views)
Hello there,

Can anyone improve on this scripting?

Seems like an array compare function would be most useful as a standard scripting function. I'm trying to simply compare to two strings (imported as U8's for Unicode and NULL '\0' reasons)

-Chroma
0 Kudos
Message 3 of 3
(3,321 Views)