Populate Multidimensional Arrays in a TestStand Statement

Updated Jan 14, 2019

Reported In

Software

  • TestStand 2014
  • TestStand 2012
  • TestStand 2012 SP1
  • TestStand 2010 SP1
  • TestStand 2010
  • TestStand 2016
  • TestStand 2016 SP1
  • TestStand 2013
  • TestStand 4.2.1

Issue Details

I am able to use the syntax Locals.myArray = {1,2,3} to populate a one dimensional array in TestStand, but I am not able to do this with multidimensional arrays.  How can I accomplish this?

Solution

In TestStand, multidimensional arrays are handled in the same way as single dimensional arrays; they are just indexed differently.  For this reason, it is necessary to first create a single dimensional array, then reshape it to the desired dimension.  For example, to specify the array {{1,2,3},{4,5,6},{7,8,9}}, the following statements are used:
//create the single dimensional array with the desired values
Locals.my2DArray={1,2,3,4,5,6,7,8,9},
//reshape the array so it is seen as 2 dimensional
SetArrayBounds(Locals.my2DArray,"[0][0]","[2][2]")

​This code results in a 2 dimensional array with the specified values:

Additional Information

This process can be used for arrays with any number of dimensions. When reshaping the array, the indices are incremented in order, starting with the first index.