NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

how to clear an array?

I want to clear an one dimension and also 2-dimension numeric arrays.  Is there a single command that does it?

 

 

Thanks

Rafi

0 Kudos
Message 1 of 8
(7,148 Views)

Hi Rafi,

 

Try this example

 

Greetings

 

juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 2 of 8
(7,124 Views)

Hi  juergen,

 

thanks for the example.  I was not aware of this way of activating the different methods.  Very nice indeed!

 

I'm still confused by the long list of methods available.  How one finds what he needs?  how do I learn what each one does.?

 

I actually didn't ask you for deleting the array elements but rather "erasing" them, or filling them with 0s.

 

I'm sure there' a method to do it, but I was unable to find it....

 

I'll appreciate if you show me the right one, and also, how to go about finding it on my own the next time?

 

thanks in advance

Rafi

0 Kudos
Message 3 of 8
(7,107 Views)

Hi Rafi,

 

To add to juergen's response.

 

The only way I know is to delete the array and then create it again of the same size. this will set the contents back to zero's

 

Also the SetDimensions is obsolete so it's wise to use the new method PropertyObjectType.ArrayDimensions.

 

You will also notice that the SetDimensions doesn't actually empty the array as the Delete does as the bounds can not be set to a value which will allow it to be empty. Also the SetDimensions will handle both one dimension and multiple dimensions eg SetDimensions("", 0, "[0]", "[9]") will set an 1D array with 10 elements.

 

Actually, NI seems to missed the opportunity with the new ArrayDimensions to provide a set of functions similarly in LabVIEW for handling array's.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 8
(7,103 Views)

HI,

 

Here is an example of using the ArrayDimensions

 

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

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

 

There is a SetBounds which you can use a long array so its of the format

 

Locals.arrTwoDim.Type.ArrayDimensions.SetBounds({0,0},{0,0})

 

Regards

Ray Farmer

 

Message Edited by Ray Farmer on 11-11-2008 09:55 PM
Regards
Ray Farmer
Message 5 of 8
(7,101 Views)

Hey Rafi,

 

Generally, you don't want to be using TestStand as a programming language.  This is why there is a limited amount of functions available.  You can use the SetValNumber method to set each elements to 0.  See the attached sequence file which shows this in action.  I simply modified the sequence file that juergen posted before.  I have an expression step that loops through each element, and sets it to zero.

For future reference, a great resource is the NI TestStand Reference Help.  For information about the API methods/properties, see the NI TestStand API Reference Help section.

Rod T.
Message 6 of 8
(7,089 Views)

Hi Rafi,

 

Sorry if have translated or missunderstood "clear" wrong.

Well Rod have figuredout an example with just one statement  which is very nice!

 

To Rod:

If you want some Kudos you should show me/us how you do this with 2-D

 

To Ray and Rod and all other members:

My example has a "bug" ! I was not able to set the 2-D to 0.
the position [0][0] is still present ! How can i set the length to 0 ?

 

 

greetings from Germany

 

juergen

 

 

  

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 7 of 8
(7,080 Views)

2-D array would require a bit more programming, and again I would recommend writing some code in a language such as LabVIEW to do this.  I suppose you could do it in TestStand using some methods and flow control.  Maybe it would go something like this if we had like a 2x10 array.

1. Obtain the size of the array using the GetDimensionsSizes method
2. Use a for loop to iterate 2 times (number of rows)

3. Nested for loop to iterate 10 times (number of columns)

4. The loop iteration will tell us the index of the 2-D array.  We can use the SetValNumber method in the same manner to set 0 to a particular element

Good luck on future projects!

Rod T.
Message 8 of 8
(7,046 Views)