Determine the Size and Dimensions of an Array in TestStand

Updated May 8, 2023

Environment

Software

  • TestStand 2016 SP1
  • TestStand 2016
  • TestStand 2014 SP1
  • TestStand 2014

I have an array in TestStand and I would like to use the TestStand API to determine the size, bounds, or dimensions of that array. Is this possible?

To get information about the size and dimensions of an array using the TestStand API, you can use the following methods: GetDimensionsSizesGetUpperBounds, and GetLowerBounds. These are all methods of a PropertyObjectType.ArrayDimensions class and are not methods of the actual array. Therefore, you must access the Type.ArrayDimensions class of your array.

Assume you have a local 2 dimensional array of numbers called MyArray [0..9][0..3] the following expressions show how to call these functions:

  •     Locals.MyArray.Type.ArrayDimensions.GetDimensionSizes() to get an array of numbers that contains the size of each dimension in the array
  •     Locals.MyArray.Type.ArrayDimensions.GetUpperBounds() to get an array of numbers that contains the highest valid index for each dimension
  •     Locals.MyArray.Type.ArrayDimensions.GetLowerBounds() to get an array of numbers that contains the lowest valid index for each dimension

These methods return an array of numbers that contains the size of each dimension in the array. To return the size of the first dimension in MyArray you could use the following code:
Locals.MyArray.Type.ArrayDimensions.GetDimensionSizes()[0]