11-10-2008 10:04 AM
I want to clear an one dimension and also 2-dimension numeric arrays. Is there a single command that does it?
Thanks
Rafi
11-11-2008 02:00 AM
11-11-2008 02:41 PM
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
11-11-2008 03:40 PM
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
11-11-2008 03:54 PM - edited 11-11-2008 03:55 PM
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
11-11-2008 06:48 PM
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.
11-12-2008 01:48 AM
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
11-13-2008 10:06 AM
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!
08-29-2024 08:30 AM
i know this is old post but for future user.
you can clear 1 or 2 dimensional array with single expression.
Locals.array={}
Regards, Bhavin