05-17-2010 05:44 PM
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
Solved! Go to Solution.
05-18-2010 12:52 AM
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
05-18-2010 01:26 AM
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
11-20-2023 11:19 AM
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. 😎
11-27-2023 06:40 AM
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?