NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to empty 2D array?

Solved!
Go to solution

Hi all,

 

How to empty 2D array in TestStand? I have a test setup sequence with several 1D and 2D arrays as local variables. At the end of this sequence the user can choose an option to rerun setup. In this case I want to empty all arrays, because not all of them are mandatory and may stay empty, according to user definitions. For emptying 1D array I'm using DeleteElements method.There are remarks in help:"This method is only valid for one-dimensional array objects. Use the PropertyObjectType.ArrayDimensions property to change the size of multi-dimensional array objects".

But PropertyObjectType.ArrayDimensions is read-only.

Thanks in advance.  
0 Kudos
Message 1 of 7
(6,036 Views)

Hi,

 

Maybe you can define the new array bounds to empty the array :  SetArrayBounds(Locals.My2DArray, "[0][0]", "[][]")

 

The result should be : My2DArray[0..empty][0..empty]

 

 

Bruno

0 Kudos
Message 2 of 7
(6,017 Views)

Hi Bruno,

 

I tried the similar option:

Locals.Array2D.Type.ArrayDimensions.SetBoundsByStrings("[0][0]","[0][0]")

But it did not work properly: the element [0][0] was not deleted.

 

0 Kudos
Message 3 of 7
(6,010 Views)

Hi Berezka,

 

To delete the last element you can then call DeleteElements:

 

Locals.Array.Type.ArrayDimensions.SetBoundsByStrings("[0]","[0]")

Locals.Array.DeleteElements(0,1,0)

 

You can then later resize the array to the proper dimensions when you are ready to use it again.  I will look to see if there are any other options. 

Cheers,
Kelly R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(5,992 Views)
Solution
Accepted by topic author Berezka

Hi,

 

SetBoundsByStrings("[0][0]","[0][0]") => 1 element : Locals.Array2D, Array of Type [0..0][0..0]

 

BUT

 

SetBoundsByStrings("[0][0]","[][]")  => no element : Locals.Array2D, Array of Type [0..empty][0..empty]

 

 

The upper bounds must be set without any number.

 

Bruno

0 Kudos
Message 5 of 7
(5,980 Views)
Thanks, it works.
0 Kudos
Message 6 of 7
(5,972 Views)

Would this not also work?

Locals.Array2D = {}

0 Kudos
Message 7 of 7
(3,427 Views)