NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to append data into array?

Solved!
Go to solution

Hi,

 

As it's in question. Can I add data (new elements) into array dynamically? Let say my Numeric array 1D is size of three, but I'd like to add next three elements. Should I change array size first?

 

Cheers,

 

K

0 Kudos
Message 1 of 5
(13,681 Views)

If you use the option = 1 in the SetVal method this will insert a new element into the array.


PropertyObject.SetValNumber ( lookupString, options = 1, newValue)

 

If you want to re- dimension the array size use the following

(for 1D arrays)
PropertyObject.SetNumElements ( numElements, options = 0)

(for multi-Dimension arrays)

PropertyObjectType.ArrayDimensions
ArrayDimensions.SetBounds ( lowerBounds, upperBounds)

 

check out the help for each of these in the TestStand Programmer Reference.

 

regards

Ray Farmer

 

Regards
Ray Farmer
Message 2 of 5
(13,667 Views)
Solution
Accepted by topic author MimiKLM

Hi K,

 

Ray is right!

 

Maybe this thread will also help you because there is smal example

http://forums.ni.com/ni/board/message?board.id=330&message.id=18421&query.id=288653#M18421

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 3 of 5
(13,663 Views)

A minor correction...

 

I'm fully aware that this thread is 13.5 years old, but I ran across it while trying to figure out if there's a more elegant way to append an element to an array.

 


@RayFarmer wrote:

If you use the option = 1 in the SetVal method this will insert a new element into the array.

If Locals.Foo is a 1D array of numbers and I try using option 1, which is PropOption_InsertElement:

Locals.SetValNumber( "Foo", PropOption_InsertElement, 123 )
,Locals.Foo.SetValNumber( "", PropOption_InsertElement, 123 )

In either case TestStand throws an error "Expected Number, found Array of Numbers."

 

However, the following does work:

Locals.Foo += { 123 }

This is more for the benefit of future readers running across this thread, as I know that @RayFarmer is a TestStand Über Overlord (an official title) at the time I'm writing this. 😎

Message 4 of 5
(2,933 Views)

Hi guys, 

 

I know this is old, but maybe you can answer my question, and help other who will be looking for this in the future.

I want to insert into array, not append.

 

I got this expression from the help:

InsertElements(MyArrayHere, ["my index here"], number of elements to insert here]

 

InsertElements(StationGlobals.SN_Buffer, ["0"],1).

 

This is accepted, but where/how do I specify the actual element I want to insert?

 

0 Kudos
Message 5 of 5
(2,865 Views)