Determine the Size and Dimensions of an Array in TestStand

Updated Nov 3, 2017

Reported In

Software

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

Issue Details

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?

Solution

To get information about the size and dimensions of an array using the TestStand API, you can use the following methods: GetDimensionsSizes, GetUpperBounds, 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]

WAS THIS ARTICLE HELPFUL?

Not Helpful