Overview
This example shows three methods of how to programmatically create a TestStand Array using the TestStand API.
Description
This example uses the following approaches to generate a new array using the TestStand API:
Creating a copy of an existing array object only at run-time
- Access the Run-time Locals container using "Locals"
- Clone the existing object using the Clone() method
- Add the new array to the Locals container using the InsertSubProperty() method
Locals.SetPropertyObject("NewArrayFromClone", PropOption_InsertIfMissing, Locals.OriginalArray.Clone("",0))
Creating a new array object only at run-time
- Access the Run-time Locals container using "Locals"
- Create a new array and insert it into the Locals container using the NewSubProperty() method
Locals.NewSubProperty("NewArraySubproperty", PropValType_Number, True, "", 0)
Creating a new array object at edit-time
- Access the Locals container for the edit copy of the sequence file (not the active sequence execution) using "RunState.SequenceFile.Data.Seq["MainSequence"].Locals"
- Create a new array and insert it into the Locals container using the NewSubProperty() method
RunState.SequenceFile.Data.Seq["MainSequence"].Locals.NewSubProperty("NewArraySubpropertyPersisted", PropValType_Number, True, "", 0)
Hardware and Software Requirements
Creating Arrays Using API - TS 2_0.seq
TestStand 2.0 or Compatible
Creating Arrays Using API - TS 2012.seq
TestStand 2012 SP1 or Compatible
Steps to Implement or Execute Code
- Open the attached sequence file
- Run the sequence using Run » Mainsequence.
- After dismissing the message box, the execution will suspend. Click the Variables tab in the sequence editor to view the newly created variables.
- Resume the execution, and close the completed execution window. Observe that the NewArraySubpropertyPersisted variable exists in your sequence.
Additional Information or References
Al B.
Staff Software Engineer - TestStand
CTA/CLD